What is the difference between Component and PureComponent? give an example where it might break my app
The main difference is pure component will re-render when only its props or state changes. On the other hand, simple component re-renders every time when its parent re-renders
I think Pure component may not detect some changes if props is nested object because of shallow comparision of pure components
I think because shouldComponentUpdate changes only part of tree and effects only specific component. But, context works in global level there might be race condition when there is gloabal changes and shouldComponentUpdate works together.
- We can wrap state related function (setState or useState) inside callback function and pass it to child component. Through, this callback function we can pass data from child to parent
- With state management library
- Pass function to child component which gets data from child component. And set data to state in parent component
- We can use shouldComponentUpdate method it class components
- With memo() function in functional components
Fragment lets you gather some elements without creating extra node on DOM. I think there might be style related issue. Because of not exsit node.
In order to create re-usable component we need HOC. From my personal experience I used HOC when I created components which have same functionalities like toggling.
Promise is an object representing intermediate state of operation which is guaranteed to complete its execution at some point in future. Async/Await is a syntactic sugar for promises, a wrapper making the code execute more synchronously. 2. Promise has 3 states – resolved, rejected and pending
We can also pass functions as parameters to other functions and call them inside the outer functions. So callback is a function that is passed to another function. When the first function is done, it will run the second function.
setState takes up to 2 arguments and because operation made with setState might be expensice it was made asyc
- Change Class to function related syntax
- Change render method to return method
- Remove constructor
- Change all methods to functions
- Replace lifesycle methods with hooks
- With importing them
- Inluce them direectly inside components
- We can use CSS in JS
We can use dangerouslySetInnerHTML to render it