Design principles for Android Widgets
masterWhen building widgets with react-native-android-widget, you must follow specific constraints because widgets are rendered by the Android system, not the React Native runtime.
Core Constraints
- No Hooks: Widget components must not use any React hooks (e.g.,
useState,useEffect). - Primitive-only UI: Widgets must be functions that return only the library's provided primitives. You cannot use standard React Native components like
View,Text, orImageinside a widget. - Synchronous Execution: You can use standard JSX, conditions, and loops (
for,map), but the component function cannot be async.
Supported Primitives
The library provides the following primitives to build your UI:
FlexWidgetOverlapWidgetListWidgetTextWidgetImageWidgetIconWidgetSvgWidget