React - Patterns
There are a few usefull patterns that can be adopted for your react application. They are a standard that is reused in lots of codebase
Higher Order Component
I know HOC pattern with which I create a wrapper that will be reused to extend functionality of existing components.
I am aware that HOC creates a new component, so it should not be used inside render function or functional component.
React.Node as props
I know that I can use properties that will accept react nodes. That way I can create additional slots inside component beside default children prop.
Event listeners with useEffect
I know that using useEffect I can attach event listeners. I remember to clean up the listeners with callback function
Render props pattern
I know that I can create component that will accept function as a children that will be executed with some context data to return JSX.
I understand that this pattern is used f.e. in components like Context.Consumer
I know HOC pattern with which I create a wrapper that will be reused to extend functionality of existing components.
I am aware that HOC creates a new component, so it should not be used inside render function or functional component.
I know that I can use properties that will accept react nodes. That way I can create additional slots inside component beside default children prop.
I know that using useEffect I can attach event listeners. I remember to clean up the listeners with callback function
I know that I can create component that will accept function as a children that will be executed with some context data to return JSX.
I understand that this pattern is used f.e. in components like Context.Consumer