fc

ReactElement fc(

  1. JSAny component, [
  2. Map<String, Object?>? props,
  3. List<ReactElement>? children
])

Creates a ReactElement from a registered function component.

This is a convenience function that combines creating props and the element.

Example:

final MyComponent = registerFunctionComponent((props) {
  return pEl('Hello ${props['name']}!');
});

// Usage: fc(MyComponent, {'name': 'World'});

Implementation

ReactElement fc(
  JSAny component, [
  Map<String, Object?>? props,
  List<ReactElement>? children,
]) => (children != null && children.isNotEmpty)
    ? createElementWithChildren(
        component,
        props != null ? createProps(props) : null,
        children,
      )
    : createElement(component, props != null ? createProps(props) : null);