rnElement
ReactElement
rnElement(
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'),
};
}