final-form / final-form/react-final-form
[Feature] Improve renderComponent
- Dominant language
- JavaScript
- Stars
- 7.4k
- Forks
- 497
- PR merge metrics
- No merged PRs in 30d
Description
The `renderComponent` function could use the react isValidElement and cloneElement functions for more flexibility (like recharts).
```js
// before
if (component) {
return React.createElement(
component,
Object.assign(lazyProps, rest, {
children,
render
})
)
}
// after
if (component) {
const elemProps = Object.assign(lazyProps, rest, {
children,
render
});
return React.isValidElement(component)
? React.cloneElement(component, elemProps) // merge props
: React.createElement(component, elemProps)
}
```
What allows to do:
```jsx
} />
} />
```
Contributor guide
Assessment
This issue has not been assessed yet.