cloneElement function

ReactElement cloneElement(
  1. ReactElement element, [
  2. Map? props,
  3. Iterable? children
])

Dart wrapper for React.cloneElement.

From the JS docs:

Clone and return a new ReactElement using element as the starting point. The resulting element will have the original element's props with the new props merged in shallowly. New children will replace existing children. Unlike React.addons.cloneWithProps, key and ref from the original element will be preserved. There is no special behavior for merging any props (unlike cloneWithProps). See the v0.13 RC2 blog post for additional details.

Implementation

ReactElement cloneElement(ReactElement element, [Map? props, Iterable? children]) {
  ArgumentError.checkNotNull(element, 'element');

  var propsChangeset = preparePropsChangeset(element, props, children);

  if (children != null) {
    return _cloneElement(element, propsChangeset, children);
  } else {
    return _cloneElement(element, propsChangeset);
  }
}