createMapper()function
createMapper(defaults: Mapping = {}): [Mapping: FunctionComponent<MappingProps>, Mapper: FunctionComponent<MapperProps>]| Param | Type | |
|---|---|---|
defaults | Mapping | The initial mapping of element types to renderer components. Defaults to {} |
| Return | |
|---|---|
[Mapping: FunctionComponent<MappingProps>, Mapper: FunctionComponent<MapperProps>] | A [Mapping, Mapper] tuple of components sharing a private context. |
Create a [Mapping, Mapper] pair of components backed by their own private React context.
Mappingextends or overrides the mapping inside a subtree (useful for swapping in custom renderers for specific element types).Mapperaccepts a pre-walked iterable of elements aschildrenand dispatches each to the registered component for itstype. Any other props passed toMapperare spread onto every dispatched child.
Each call creates its own context — independent mappers don't interfere with each other.