Skip to content

Improve React HOC types #1987

Open
Open
@sdirix

Description

@sdirix

Is your feature request related to a problem? Please describe.

The HOCs are implemented generically, i.e. they pass unknown props through to the wrapped component. However this is not reflected in their type.

Describe the solution you'd like

We need some way to indicate that our HOCs pass through unknown types. One possible approach is using generics, e.g. adapt

export const withJsonFormsControlProps =
  (Component: ComponentType<ControlProps>, memoize = true): ComponentType<OwnPropsOfControl> =>
  withJsonFormsContext(withContextToControlProps(memoize ? React.memo(Component) : Component));

to

export const withJsonFormsControlProps = <T>
  (Component: ComponentType<ControlProps & T>, memoize = true): ComponentType<OwnPropsOfControl & T> =>
  withJsonFormsContext(withContextToControlProps(memoize ? React.memo(Component) : Component));

This approach and alternatives should be evaluated and implemented.

After the implementation the order of independent HOCs should no longer matter, see here for example.

Describe alternatives you've considered

Don't generify the HOCs.

Framework

React

RendererSet

Other (please specify in the Additional context field)

Additional context

any renderer set

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions