I have a component with a couple of input fields that updates the state of the component using the valueLink={this.linkState('foo')}
facility provided by React.addons.LinkedStateMixin
.
Prior to this I was using the onChange
handler to communicate the changes back to the server using a websocket connection, so I was wondering if I could replicate this behaviour somewhat and post the changes in the state back using a "state change listener" of some sorts?
React components has a built-in state object. The state object is where you store property values that belongs to the component. When the state object changes, the component re-renders.
When using React, you generally don't need to call addEventListener to add listeners to a DOM element after it is created. Instead, just provide a listener when the element is initially rendered. You have to be careful about the meaning of this in JSX callbacks. In JavaScript, class methods are not bound by default.
setState" function is used to change the state of the React. js component.
React will then look at the virtual DOM, it also has a copy of the old virtual DOM, that is why we shouldn't update the state directly, so we can have two different object references in memory, we have the old virtual DOM as well as the new virtual DOM.
Looks like the method I am looking for is componentDidUpdate()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With