Allow Writable to have multiple children

This commit is contained in:
Deluan 2020-06-05 11:45:46 -04:00
parent 79cf33281c
commit e9115dab4c

View File

@ -1,4 +1,4 @@
import { cloneElement } from 'react' import { cloneElement, Children, isValidElement } from 'react'
export const isWritable = (owner) => { export const isWritable = (owner) => {
return ( return (
@ -14,7 +14,9 @@ export const isReadOnly = (owner) => {
const Writable = (props) => { const Writable = (props) => {
const { record, children } = props const { record, children } = props
if (isWritable(record.owner)) { if (isWritable(record.owner)) {
return cloneElement(children, props) return Children.map(children, (child) =>
isValidElement(child) ? cloneElement(child, props) : child
)
} }
return null return null
} }