Skip to content

Instantly share code, notes, and snippets.

@rsxdalv
Last active October 26, 2018 14:26
Show Gist options
  • Save rsxdalv/7b8ce974222b95aec1bf3036adee3701 to your computer and use it in GitHub Desktop.
Save rsxdalv/7b8ce974222b95aec1bf3036adee3701 to your computer and use it in GitHub Desktop.
const isElementTextAreaConnected = (x): x is React.SFCElement<typeof TextAreaConnected> =>
typeof x === "object"
&& typeof x.type !== "string"
&& areComponentsEqual(x.type, TextAreaConnected)
const BlackMagicBoxV2 = ({ children, y = { i: 0, j: 0 } }) => {
return React.Children.map(children, x => {
if (typeof x === "object") {
return isElementTextAreaConnected(x) ?
React.cloneElement<any, {}>(x, { i: y.j++ }) :
React.cloneElement(x, {
children: BlackMagicBoxV2({ children: x.props.children, y })
});
} else {
return x;
}
}) as any;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment