Say I have ComponentA and ComponentB. ComponentA will render() some arbitrary element tree that includes B at arbitrary locations. I want to change all of the myValue props on ComponentB to be prefixed with the value '_'. How can I do this?
I want this:
class ComponentA extends React.Component {
render() {
return (
<div>
<ComponentB myValue={something} />
<div><ComponentB myValue={something2} />
</div>
)
}
}
to become this:
class ComponentA extends React.Component {
render() {
return (
<div>
<ComponentB myValue={'_' + something} />
<div><ComponentB myValue={'_' + something2} />
</div>
)
}
}
Also, the replaceDivsWithSpans example from the README uses DOMElement in the visitor, but what would I use for a component (not a component element)? Using ComponentElement works for e.g. transformComponents(wrapRender(transformNode))(<ComponentA/>) but not transformComponents(wrapRender(transformNode))(ComponentA). No method on my visitor gets called (e.g. ComponentElement). I'm not sure if this is because I'm using React 15.3?
Say I have ComponentA and ComponentB. ComponentA will render() some arbitrary element tree that includes B at arbitrary locations. I want to change all of the
myValueprops on ComponentB to be prefixed with the value '_'. How can I do this?I want this:
to become this:
Also, the
replaceDivsWithSpansexample from the README usesDOMElementin the visitor, but what would I use for a component (not a component element)? UsingComponentElementworks for e.g.transformComponents(wrapRender(transformNode))(<ComponentA/>)but nottransformComponents(wrapRender(transformNode))(ComponentA). No method on my visitor gets called (e.g.ComponentElement). I'm not sure if this is because I'm using React 15.3?