babel-plugin-jsx-adopt
babel-plugin-jsx-adopt copied to clipboard
Multiple arguments?
Is this possible? I couldn't make it work
<Grid >
{(item, opened, toggle) => {
a possible solution could be
const [item, opened, toggle] = adopt(<Grid />)
That's not quite possible, because it would be ambigous with:
<Grid >
{([item, opened, toggle]) => {
And I can't statically know which one do you want. Supporting the given by me example allows for a good interoperability with existing, built in mechanism of context (which always provide a single argument to ur render props, which might be an array)
Makes sense. adoptObj/adoptArray would work, but it's ugly. I'll carry on trying to avoid ...args
.
adaptObj
actually would not be needed because this:
const { item, opened, toggle } = adopt(<Grid />)
is very much supported - it's a single destructured argument.
I would generally advise of avoiding ...args
in render props and stick to a single argument to keep "compatibility" with what kind of APIs React provides.