I would like to know if it is posible to add a new prop to a component instance, the component instance look like this:
Maybe is a bad practice modifying a component instance directly, but I wonder if it is possible or not.
I would like to know if it is posible to add a new prop to a component instance, the component instance look like this:
Maybe is a bad practice modifying a component instance directly, but I wonder if it is possible or not.
You can do this by using React.cloneElement
:
const changeProp = (component) => (
{React.cloneElement(component, {
someProp: { value }
})}
)
Reference to react docs: https://reactjs.org/docs/react-api.html#cloneelement