dart_node_react_native library
React Native bindings for Dart
Classes
-
ReducerHook<
TState, TAction> - The return value of useReducer.
-
StateHook<
T> - The return value of useState.
- StateHookJS
- State hook for JS interop types (JSString, JSObject, etc).
-
StateHookJSArray<
T extends JSAny> - State hook for lists of JS objects.
- TestNode
- A node in the test render tree representing a React Native component.
- TestRenderResult
- Result of rendering a component for testing.
Extension Types
- AppRegistry
- AppRegistry for registering the root component
- ReactNative
- React Native core - accessed via require('react-native')
- RNActivityIndicatorElement
- ActivityIndicator component type
- RNButtonElement
- Button component type
- RNFlatListElement
- FlatList component type
- RNImageElement
- Image component type
- RNSafeAreaViewElement
- SafeAreaView component type
- RNScrollViewElement
- ScrollView component type
- RNSwitchElement
- Switch component type
- RNTextElement
- Text component type
- RNTextInputElement
- TextInput component type
- RNTouchableOpacityElement
- TouchableOpacity component type
- RNViewElement
- View component type
Properties
- appRegistry → AppRegistry
-
Get AppRegistry from react-native
no setter
- reactNative → ReactNative
-
The global React Native module instance.
no setter
Functions
-
activityIndicator(
{bool? animating, String? color, String? size, Map< String, dynamic> ? props}) → RNActivityIndicatorElement - ActivityIndicator component
-
createElement(
JSAny type, [JSObject? props, JSAny? children]) → ReactElement - Create a React element (convenience wrapper)
-
createElementWithChildren(
JSAny type, JSObject? props, List< JSAny> children) → ReactElement - Create a React element with multiple children using spread
-
createFunctionalComponent(
ReactElement render(JSObject props)) → JSFunction - Create a functional component - returns the component function itself.
-
createProps(
Map< String, dynamic> props) → JSObject - Create props object from a Map (with function conversion)
-
flatList(
{required JSArray< JSAny?> data, required JSFunction renderItem, JSFunction? keyExtractor, Map<String, dynamic> ? style, Map<String, dynamic> ? props}) → RNFlatListElement - FlatList component
-
functionalComponent(
String name, ReactElement render(JSObject props)) → ReactElement - Create a React element with an inline functional component.
-
registerApp(
String appName, JSFunction component) → void - Register the main app component
-
renderForTest(
ReactElement element) → TestRenderResult - Render a React element for testing.
-
rnButton(
{required String title, void onPress()?, String? color, bool? disabled, Map< String, dynamic> ? props}) → RNButtonElement - Button component
-
rnElement(
String componentName, {Map< String, dynamic> ? props, List<ReactElement> ? children, JSAny? child}) → ReactElement - Create a React Native element Note: child accepts JSAny? to support both ReactElement and text strings
-
rnImage(
{required Map< String, dynamic> source, Map<String, dynamic> ? style, String? resizeMode, Map<String, dynamic> ? props}) → RNImageElement - Image component
-
rnSwitch(
{bool? value, void onValueChange(bool)?, String? trackColor, String? thumbColor, Map< String, dynamic> ? props}) → RNSwitchElement - Switch component
-
safeAreaView(
{Map< String, dynamic> ? style, Map<String, dynamic> ? props, List<ReactElement> ? children, JSAny? child}) → RNSafeAreaViewElement - SafeAreaView component
-
scrollView(
{Map< String, dynamic> ? style, Map<String, dynamic> ? contentContainerStyle, Map<String, dynamic> ? props, List<ReactElement> ? children, JSAny? child}) → RNScrollViewElement - ScrollView component
-
setupTestEnvironment(
) → void - Install mock React Native components for testing
-
text(
String content, {Map< String, dynamic> ? style, Map<String, dynamic> ? props, void onPress()?}) → RNTextElement - Text component
-
textInput(
{String? value, String? placeholder, bool? secureTextEntry, void onChangeText(String)?, Map< String, dynamic> ? style, Map<String, dynamic> ? props}) → RNTextInputElement - TextInput component
-
touchableOpacity(
{void onPress()?, Map< String, dynamic> ? style, Map<String, dynamic> ? props, List<ReactElement> ? children, JSAny? child}) → RNTouchableOpacityElement - TouchableOpacity component
-
useCallback(
Function callback, List< Object?> dependencies) → JSFunction -
Returns a memoized version of
callbackthat only changes if one of thedependencieshas changed. -
useDebugValue<
T> (T value, [String format(T)?]) → void -
Displays
valueas a label for a custom hook in React DevTools. -
useEffect(
Object? sideEffect(), [List< Object?> ? dependencies]) → void -
Runs
sideEffectafter every completed render of a function component. -
useImperativeHandle<
T> (Object? ref, T createHandle(), [List< Object?> ? dependencies]) → void -
Customizes the
refvalue that is exposed to parent components when using forwardRef2 by settingref.currentto the return value ofcreateHandle. -
useLayoutEffect(
Object? sideEffect(), [List< Object?> ? dependencies]) → void -
Runs
sideEffectsynchronously after a function component renders, but before the screen is updated. -
useMemo<
T> (T createFunction(), [List< Object?> ? dependencies]) → T -
Returns a memoized version of the return value of
createFunction. -
userClear(
TestNode input) → void - Clear a text input
-
useReducer<
TState, TAction> (TState reducer(TState state, TAction action), TState initialState) → ReducerHook< TState, TAction> -
Initializes state of a function component to
initialStateand creates adispatchmethod. -
useReducerLazy<
TState, TAction, TInit> (TState reducer(TState state, TAction action), TInit initialArg, TState init(TInit)) → ReducerHook< TState, TAction> -
Initializes state of a function component to
init(initialArg)and createsdispatchmethod. -
useRef<
T> ([T? initialValue]) → Ref< T?> -
Returns an empty mutable
Refobject. -
useRefInit<
T> (T initialValue) → Ref< T> -
Returns a mutable
Refobject withRef.currentproperty initialized toinitialValue. -
userPress(
TestNode node) → void - Simulate pressing a touchable element
-
userType(
TestNode input, String text) → Future< void> - Simulate typing into a TextInput.
-
useState<
T> (T initialValue) → StateHook< T> -
Adds local state to a function component by returning a StateHook with
StateHook.value initialized to
initialValue. -
useStateJS(
JSAny? initialValue) → StateHookJS - Adds local state for JS interop types to a function component.
-
useStateJSArray<
T extends JSAny> (JSAny? initialValue) → StateHookJSArray< T> - Adds local state for lists of JS objects to a function component.
-
useStateLazy<
T> (T init()) → StateHook< T> -
Adds local state to a function component by returning a StateHook with
StateHook.value initialized to the return value of
init. -
view(
{Map< String, dynamic> ? style, Map<String, dynamic> ? props, List<ReactElement> ? children, JSAny? child, void onPress()?}) → RNViewElement - View component - the fundamental building block
Exceptions / Errors
- TestingException
- Exception thrown by testing library.