3 ms·
In preactjs, how do you update the screen when data changes? According to the site preactjs is stateless, so presumably there is no updateState() but there is n
by interlocutor 10y ago
In preactjs, how do you update the screen when data changes? According to the site preactjs is stateless, so presumably there is no updateState() but there is no alternative mentioned.
- rublev 10y agoComponent lifecycle methods. There's two types of components in preact: - Classical Components, with lifecycle methods and state - Stateless Functional Components, which are functions that accept props and return JSX.
- interlocutor 10y agoSorry, can you elaborate? How are lifecycle methods useful for updating the screen when data changes? Component lifecycle methods are componentWillMount, componentDidUnmount etc. But my data may change at any time, and I want to update the screen when my data changes, and I can't wait for the next component lifecycle method invocation.
- TheCoelacanth 10y agoNot sure if I understand what you are asking. It is basically the same as react, you either call setState on the component or pass in different props to the component and then the component gets re-rendered with the new state/props.
- nine_k 10y agoLikely you dispatch an event that updates some props, and your components render themselves again with a new props configuration? All the state you have in a functional program is usually your cal stack and/or message queue.