eclipsesource / eclipsesource/jsonforms

Improve React HOC types

Open
#1,987 0 comments 0 reactions 2 assignees Claimed by @sdirix View on GitHub
enhancement react
Dominant language
TypeScript
Stars
2.7k
Forks
424
Avg merge
17d 8h
Merged PRs (30d)
1

Description

### 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, memoize = true): ComponentType =>
withJsonFormsContext(withContextToControlProps(memoize ? React.memo(Component) : Component));
```
to
```
export const withJsonFormsControlProps =
(Component: ComponentType, memoize = true): ComponentType =>
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](https://github.com/eclipsesource/jsonforms/blob/96be5205ba37203b25485e274b3ca94d30f8616d/packages/material-renderers/src/cells/MaterialEnumCell.tsx#L46-L47).

### 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.