Originally developed for Facebook, React is a JavaScript library that builds user interfaces for single-page applications by dividing UI into composable components. Since it requires only a minimal understanding of HTML and JavaScript, React has risen in popularity as a front-end web development tool.
What problem does Redux solve?
Redux provides a solution by ensuring that: Your state is wrapped in a store which handles all updates and notifies all code that subscribes to the store of updates to the state.
Conditional rendering. Beta-ReactJS
Conditional rendering. ReactJS
Conditional Rendering 7 ways. Digital Ocean
Conditional rendering 9 methods. Logrocket
Keys help React identify which items have changed, are added, or are removed. The best way to pick a key is to use a string that uniquely identifies a list item among its siblings.
When you don't have stable IDs for rendered items, you may use the item index as a key as a last resort but is not recommended if the order of items may change. This can negatively impact performance and may cause issues with component state.
Index as a key is an anti-pattern. MediumReact Component. ReactJS
React Lifecycle. Order of invocation. W3Schools
(Add more information)
What is prop drilling? Prop drilling is the unofficial term for passing data through several nested children components, in a bid to deliver this data to a deeply-nested component. The problem with this approach is that most of the components through which this data is passed have no actual need for this data.
When you use useState, useEffect(mount, update, unmount) and useContext?
Optimization: Pure components, useMemo(), useCallback(), memo. (re-renders).
React.PureComponent is similar to React.Component. The difference between them is that React.Component doesn't implement shouldComponentUpdate(), but React.PureComponent implements it with a shallow prop and state comparison.
If your React component's render() function renders the same result given the same props and state, you can use React.PureComponent for a performance boost in some cases.
Note
*React.PureComponent's shouldComponentUpdate() only shallowly compares the objects. If these contain complex data structures, it may produce false-negatives for deeper differences. Only extend PureComponent when you expect to have simple props and state, or use forceUpdate() when you know deep data structures have changed. Or, consider using immutable objects to facilitate fast comparisons of nested data.
Furthermore, React.PureComponent's shouldComponentUpdate() skips prop updates for the whole component subtree. Make sure all the children components are also “pure”.*
React API. ReactJSA higher-order component (HOC) is an advanced technique in React for reusing component logic. HOCs are not part of the React API, per se. They are a pattern that emerges from React’s compositional nature.
Concretely, a higher-order component is a function that takes a component and returns a new component.
const EnhancedComponent = higherOrderComponent(WrappedComponent);
Whereas a component transforms props into UI, a higher-order component transforms a component into another component.
HOCs are common in third-party React libraries, such as Redux’s connect and Relay’s createFragmentContainer.
High Order Components. ReactJSThe term "render prop" refers to a technique for sharing code between React components using a prop whose value is a function.
A component with a render prop takes a function that returns a React element and calls it instead of implementing its own render logic.
<DataProvider render={data => (
<h1>Hello {data.target}</h1>
)}/>
Libraries that use render props include React Router, Downshift and Formik.
Render props. ReactJSBuilding your own Hooks lets you extract component logic into reusable functions.
Building your own Hooks. ReactJS