rnElement

ReactElement rnElement(

  1. String componentName, {
  2. Map<String, dynamic>? props,
  3. List<ReactElement>? children,
  4. JSAny? child,
})

Create a React Native element Note: child accepts JSAny? to support both ReactElement and text strings

Implementation

ReactElement rnElement(
  String componentName, {
  Map<String, dynamic>? props,
  List<ReactElement>? children,
  JSAny? child,
}) {
  final component = reactNative[componentName];
  final jsProps = (props != null) ? createProps(props) : null;

return switch (component) { final JSAny c => (children != null && children.isNotEmpty) ? createElementWithChildren(c, jsProps, children) : (child != null) ? createElement(c, jsProps, child) : createElement(c, jsProps), _ => throw StateError('Component $componentName not found'), }; }