Last active
October 26, 2018 14:26
-
-
Save rsxdalv/7b8ce974222b95aec1bf3036adee3701 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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