Open atherdon opened 6 years ago
Learned about the component life cycle, which are a series of actions which are executed:
Also learned how to dynamically render a message when the state is updated. By modifying our state:
state = { meal: '', meals: [], showAddMealMessage: false };
Adding our componentDidUpdate() function:
componentDidUpdate(prevProps, prevState) { if (prevState.meals.length < this.state.meals.length) { this.setState({showAddMealMessage: true}); setTimeout(() => this.setState({showAddMealMessage: false}), 1000); } }
And adding this line of code when we render:
{this.state.showAddMealMessage ?
New meal added
: null}assume you have a profile form, with default fields like email, username, image, description, etc. imagine how you'll create it and tell me how you'll handle a default form flow like updates, validation, etc. based on what you learn at this chapter.
if you'll reply to my last comment, i think we can close this task and move to most interesting part of this course. Chapter 8 is really important for me, because it's introduce you to my projects, that we're currently working on
https://medium.com/quick-code/lets-learn-react-chapter-7-component-life-cycle-6aaa815747db
Expected result
Test
1