4 ms·
Component lifecycle methods. There's two types of components in preact: - Classical Components, with lifecycle methods and state - Stateless Functional Compon
by rublev 10y ago
Component 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.