Skip to main content

API

beyond(cmp, config)

Applies a React Beyond configuration to the component cmp and returns the new component. The configuration will be applied to all descendants of cmp as well.

  • cmp: The root component that you want to apply the configuration to.

Config object

PropertyTypeDescription
idstringThe id of the HOC. Must be a unique string. This will appear appear next to the components in React DevTools.
mapComponent?(cmp: FC) => FCA function that maps a component to a new component. If defined, all the components under the deep HOC will be mapped with this function. This function is called once per mounted components.
invokeRender?(render, props, ref) => ReactElementA function which invokes the base component with the passed props and ref. If defined, all the components under the deep HOC will be rendered through this function. render is always the render function, unwrapped from eventual forwardRef and/or memo wrappings. This function is called once per render. Defaults to (render, props, ref) => render(props, ref)
mapElement?(el: ReactElement, magicPropValue?: any) => ReactElementA function that maps el to a new element. If defined, all elements under the deep HOC will be mapped with it. magicPropValue will only be passed, when magicProp is defined; see below.
directiveProp?stringIf defined, mapElement will only be called, if a JSX element has a prop with <magicProp> prop name. If so, React Beyond removes the magic prop from the props object, and calls mapElement with (originalProps, magicPropValue).