This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
reactjs_and_friends [2021/11/03 10:43] sausage [actions.js] |
reactjs_and_friends [2021/11/03 21:02] sausage |
||
---|---|---|---|
Line 301: | Line 301: | ||
The useEffect hook is going to be used as the trigger to load data into the application when it first starts. Providing an empty array to useEffect is the equivalent to the old-school lifecycle method ''componentDidMount''. Therefore, the loading will only occur on first load and will then push the data into the store. | The useEffect hook is going to be used as the trigger to load data into the application when it first starts. Providing an empty array to useEffect is the equivalent to the old-school lifecycle method ''componentDidMount''. Therefore, the loading will only occur on first load and will then push the data into the store. | ||
- | However, do notice that I have passed in ''dispatch'' in the array for useEffect. This still behaves like ''componentDidMount'' but will remove an ugly lint warning. | + | <WRAP center round info 90%> |
+ | Notice that I have passed in ''dispatch'' into the array for useEffect. This is to remove an ugly warning. Because the array with ''dispatch'' is unchanging, useEffect still behaves like ''componentDidMount''. | ||
+ | </WRAP> | ||
The ''Router'' is added here, which contains ''NavLink''s. These are used instead of a ''Nav'', because NavLinks allow the styling of the actively selected tab or navigation element. | The ''Router'' is added here, which contains ''NavLink''s. These are used instead of a ''Nav'', because NavLinks allow the styling of the actively selected tab or navigation element. | ||
Line 473: | Line 475: | ||
There has been no need to implement any local state in any of the components. All have been driven by the useSelector hook back from the main application state. | There has been no need to implement any local state in any of the components. All have been driven by the useSelector hook back from the main application state. | ||
+ | |||
+ | Finally a big thanks to my friends Andrew and Adam for reviewing the content of this article for me. | ||
===== References and further reading ===== | ===== References and further reading ===== |