Closed alberto-portilla closed 8 years ago
Can you be more specific? with Om you access state like (om/get-state this)
. Please provide some code example if possible.
Sure! Every material-ui component has a state key isClean
(along with some others as hasValue
or isFocused
. You can check this with react tools by inspecting a TextField component. usually you can access this state key in jsx by using {this.state.isClean}
. I cant figure out how to do this while declaring the component with the library, i could use component refs, but this breaks encapsulation.
The (om/get state this)
needs a component, and im not able to get the reference to react object in the cljs context, because (this-as)
return a plain js object. Id appreciate so much if you can help me
Okay, I see. I don't think you can (and should) access it's internal state from the outside. What should be accessed from outside is in their docs http://www.material-ui.com/#/components/text-field . For your particular problem, error text in material-ui works like, if errorText
property is not empty error is displayed otherwise not. If this isn't sufficient for your problem, you can still make wrapper component, which keeps its internal state however you want and creates text-field
accordingly.
Understood, ill follow your advice on creating a wrapper component. Thanks for the tip!
How can i access the state of a component? For instance, i need to show the error message only if the content doesn't comply with a schema and its state is not clean.