Reputation: 1085
Live Preview: https://www.webpackbin.com/bins/-KoSqF5OB0IRtbBEi822
Im trying to Clone and Modify a React Element Object.
I'm removing the inline styles of react element by cloning and adding css rules to stylesheet
Im using this function
I want to know how can i access the React Render function return value from the Element's Class ?
const Div = () => (<div></div>); // not working
const Div = (<div></div>); // working
const NewDiv = noInline(Div); // calling function
Upvotes: 1
Views: 1349
Reputation: 6132
I believe to do it you need to get a reference to the element in the render
function, and that element should be one of the component child elements — so traverse this.props.children
and find the element you are looking for. Something like this:
render () {
let children = React.Children.toArray(this.props.children);
children.forEach((child) => doSomething(child))
}
Upvotes: 1