In ember I could write something like this:
statusChanged(){
//...do some code
}.observes('observableProperty')
What is the right way to do the similar work in React.js?
You can do your logic in component lifecycle methods componentWillMount
, componentWillReceiveProps
and others. Whenever you pass new props to a component it will run throutg lifecycle. Read more about it
Alternatively you can use Rx.js . But conceptually I dont think it is a correct approach. React implies you to manipulate props and states of a component and handle all logic in lifecycle or in synthetic events.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.