From 3f93d77c0f6d8187339befe4ab3d2fcb50a092ad Mon Sep 17 00:00:00 2001 From: sudheerj Date: Sat, 10 Dec 2022 14:27:45 +0800 Subject: [PATCH 001/149] Add codingninja collab --- README.md | 7024 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 7024 insertions(+) diff --git a/README.md b/README.md index e69de29b..e412a3a2 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,7024 @@ +# React Interview Questions & Answers + +> Click :star:if you like the project. Pull Request are highly appreciated. Follow me [@SudheerJonna](https://twitter.com/SudheerJonna) for technical updates. + +--- + +

+ + Codestudio Logo + +

+ Explore the Best Free Resource to learn React and kickstart your journey as a react developer here. Earn a free certification in just 40 days. +

+

+ +--- + +
+Learn to code and get hired with Zero To Mastery: +
    +
  1. This React course is good if you’re struggling to learn React beyond the basics
  2. +
  3. This coding interview bootcamp is helpful if you’re serious about getting hired as a developer
  4. +
+
+ +--- + + +**Note:** This repository is specific to ReactJS. Please check [Javascript Interview questions](https://github.com/sudheerj/javascript-interview-questions) for core javascript questions. + +## Downloading PDF/Epub formats + +You can download the PDF and Epub version of this repository from the latest run on the [actions tab](https://github.com/sudheerj/reactjs-interview-questions/actions). + +### Table of Contents + +| No. | Questions | +| --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| | **Core React** | +| 1 | [What is React?](#what-is-react) | +| 2 | [What are the major features of React?](#what-are-the-major-features-of-react) | +| 3 | [What is JSX?](#what-is-jsx) | +| 4 | [What is the difference between Element and Component?](#what-is-the-difference-between-element-and-component) | +| 5 | [How to create components in React?](#how-to-create-components-in-react) | +| 6 | [When to use a Class Component over a Function Component?](#when-to-use-a-class-component-over-a-function-component) | +| 7 | [What are Pure Components?](#what-are-pure-components) | +| 8 | [What is state in React?](#what-is-state-in-react) | +| 9 | [What are props in React?](#what-are-props-in-react) | +| 10 | [What is the difference between state and props?](#what-is-the-difference-between-state-and-props) | +| 11 | [Why should we not update the state directly?](#why-should-we-not-update-the-state-directly) | +| 12 | [What is the purpose of callback function as an argument of setState()?](#what-is-the-purpose-of-callback-function-as-an-argument-of-setstate) | +| 13 | [What is the difference between HTML and React event handling?](#what-is-the-difference-between-html-and-react-event-handling) | +| 14 | [How to bind methods or event handlers in JSX callbacks?](#how-to-bind-methods-or-event-handlers-in-jsx-callbacks) | +| 15 | [How to pass a parameter to an event handler or callback?](#how-to-pass-a-parameter-to-an-event-handler-or-callback) | +| 16 | [What are synthetic events in React?](#what-are-synthetic-events-in-react) | +| 17 | [What are inline conditional expressions?](#what-are-inline-conditional-expressions) | +| 18 | [What is "key" prop and what is the benefit of using it in arrays of elements?](#what-is-key-prop-and-what-is-the-benefit-of-using-it-in-arrays-of-elements) | +| 19 | [What is the use of refs?](#what-is-the-use-of-refs) | +| 20 | [How to create refs?](#how-to-create-refs) | +| 21 | [What are forward refs?](#what-are-forward-refs) | +| 22 | [Which is preferred option with in callback refs and findDOMNode()?](#which-is-preferred-option-with-in-callback-refs-and-finddomnode) | +| 23 | [Why are String Refs legacy?](#why-are-string-refs-legacy) | +| 24 | [What is Virtual DOM?](#what-is-virtual-dom) | +| 25 | [How Virtual DOM works?](#how-virtual-dom-works) | +| 26 | [What is the difference between Shadow DOM and Virtual DOM?](#what-is-the-difference-between-shadow-dom-and-virtual-dom) | +| 27 | [What is React Fiber?](#what-is-react-fiber) | +| 28 | [What is the main goal of React Fiber?](#what-is-the-main-goal-of-react-fiber) | +| 29 | [What are controlled components?](#what-are-controlled-components) | +| 30 | [What are uncontrolled components?](#what-are-uncontrolled-components) | +| 31 | [What is the difference between createElement and cloneElement?](#what-is-the-difference-between-createelement-and-cloneelement) | +| 32 | [What is Lifting State Up in React?](#what-is-lifting-state-up-in-react) | +| 33 | [What are the different phases of component lifecycle?](#what-are-the-different-phases-of-component-lifecycle) | +| 34 | [What are the lifecycle methods of React?](#what-are-the-lifecycle-methods-of-react) | +| 35 | [What are Higher-Order components?](#what-are-higher-order-components) | +| 36 | [How to create props proxy for HOC component?](#how-to-create-props-proxy-for-hoc-component) | +| 37 | [What is context?](#what-is-context) | +| 38 | [What is children prop?](#what-is-children-prop) | +| 39 | [How to write comments in React?](#how-to-write-comments-in-react) | +| 40 | [What is the purpose of using super constructor with props argument?](#what-is-the-purpose-of-using-super-constructor-with-props-argument) | +| 41 | [What is reconciliation?](#what-is-reconciliation) | +| 42 | [How to set state with a dynamic key name?](#how-to-set-state-with-a-dynamic-key-name) | +| 43 | [What would be the common mistake of function being called every time the component renders?](#what-would-be-the-common-mistake-of-function-being-called-every-time-the-component-renders) | +| 44 | [Is lazy function supports named exports?](#is-lazy-function-supports-named-exports) | +| 45 | [Why React uses className over class attribute?](#why-react-uses-classname-over-class-attribute) | +| 46 | [What are fragments?](#what-are-fragments) | +| 47 | [Why fragments are better than container divs?](#why-fragments-are-better-than-container-divs) | +| 48 | [What are portals in React?](#what-are-portals-in-react) | +| 49 | [What are stateless components?](#what-are-stateless-components) | +| 50 | [What are stateful components?](#what-are-stateful-components) | +| 51 | [How to apply validation on props in React?](#how-to-apply-validation-on-props-in-react) | +| 52 | [What are the advantages of React?](#what-are-the-advantages-of-react) | +| 53 | [What are the limitations of React?](#what-are-the-limitations-of-react) | +| 54 | [What are error boundaries in React v16](#what-are-error-boundaries-in-react-v16) | +| 55 | [How are error boundaries handled in React v15?](#how-are-error-boundaries-handled-in-react-v15) | +| 56 | [What are the recommended ways for static type checking?](#what-are-the-recommended-ways-for-static-type-checking) | +| 57 | [What is the use of react-dom package?](#what-is-the-use-of-react-dom-package) | +| 58 | [What is the purpose of render method of react-dom?](#what-is-the-purpose-of-render-method-of-react-dom) | +| 59 | [What is ReactDOMServer?](#what-is-reactdomserver) | +| 60 | [How to use InnerHtml in React?](#how-to-use-innerhtml-in-react) | +| 61 | [How to use styles in React?](#how-to-use-styles-in-react) | +| 62 | [How events are different in React?](#how-events-are-different-in-react) | +| 63 | [What will happen if you use setState in constructor?](#what-will-happen-if-you-use-setstate-in-constructor) | +| 64 | [What is the impact of indexes as keys?](#what-is-the-impact-of-indexes-as-keys) | +| 65 | [Is it good to use setState() in componentWillMount() method?](#is-it-good-to-use-setstate-in-componentwillmount-method) | +| 66 | [What will happen if you use props in initial state?](#what-will-happen-if-you-use-props-in-initial-state) | +| 67 | [How do you conditionally render components?](#how-do-you-conditionally-render-components) | +| 68 | [Why we need to be careful when spreading props on DOM elements??](#why-we-need-to-be-careful-when-spreading-props-on-dom-elements) | +| 69 | [How you use decorators in React?](#how-you-use-decorators-in-react) | +| 70 | [How do you memoize a component?](#how-do-you-memoize-a-component) | +| 71 | [How you implement Server-Side Rendering or SSR?](#how-you-implement-server-side-rendering-or-ssr) | +| 72 | [How to enable production mode in React?](#how-to-enable-production-mode-in-react) | +| 73 | [What is CRA and its benefits?](#what-is-cra-and-its-benefits) | +| 74 | [What is the lifecycle methods order in mounting?](#what-is-the-lifecycle-methods-order-in-mounting) | +| 75 | [What are the lifecycle methods going to be deprecated in React v16?](#what-are-the-lifecycle-methods-going-to-be-deprecated-in-react-v16) | +| 76 | [What is the purpose of getDerivedStateFromProps() lifecycle method?](#what-is-the-purpose-of-getderivedstatefromprops-lifecycle-method) | +| 77 | [What is the purpose of getSnapshotBeforeUpdate() lifecycle method?](#what-is-the-purpose-of-getsnapshotbeforeupdate-lifecycle-method) | +| 78 | [Do Hooks replace render props and higher order components?](#do-hooks-replace-render-props-and-higher-order-components) | +| 79 | [What is the recommended way for naming components?](#what-is-the-recommended-way-for-naming-components) | +| 80 | [What is the recommended ordering of methods in component class?](#what-is-the-recommended-ordering-of-methods-in-component-class) | +| 81 | [What is a switching component?](#what-is-a-switching-component) | +| 82 | [Why we need to pass a function to setState()?](#why-we-need-to-pass-a-function-to-setstate) | +| 83 | [What is strict mode in React?](#what-is-strict-mode-in-react) | +| 84 | [What are React Mixins?](#what-are-react-mixins) | +| 85 | [Why is isMounted() an anti-pattern and what is the proper solution?](#why-is-ismounted-an-anti-pattern-and-what-is-the-proper-solution) | +| 86 | [What are the Pointer Events supported in React?](#what-are-the-pointer-events-supported-in-react) | +| 87 | [Why should component names start with capital letter?](#why-should-component-names-start-with-capital-letter) | +| 88 | [Are custom DOM attributes supported in React v16?](#are-custom-dom-attributes-supported-in-react-v16) | +| 89 | [What is the difference between constructor and getInitialState?](#what-is-the-difference-between-constructor-and-getinitialstate) | +| 90 | [Can you force a component to re-render without calling setState?](#can-you-force-a-component-to-re-render-without-calling-setstate) | +| 91 | [What is the difference between super() and super(props) in React using ES6 classes?](#what-is-the-difference-between-super-and-superprops-in-react-using-es6-classes) | +| 92 | [How to loop inside JSX?](#how-to-loop-inside-jsx) | +| 93 | [How do you access props in attribute quotes?](#how-do-you-access-props-in-attribute-quotes) | +| 94 | [What is React PropType array with shape?](#what-is-react-proptype-array-with-shape) | +| 95 | [How to conditionally apply class attributes?](#how-to-conditionally-apply-class-attributes) | +| 96 | [What is the difference between React and ReactDOM?](#what-is-the-difference-between-react-and-reactdom) | +| 97 | [Why ReactDOM is separated from React?](#why-reactdom-is-separated-from-react) | +| 98 | [How to use React label element?](#how-to-use-react-label-element) | +| 99 | [How to combine multiple inline style objects?](#how-to-combine-multiple-inline-style-objects) | +| 100 | [How to re-render the view when the browser is resized?](#how-to-re-render-the-view-when-the-browser-is-resized) | +| 101 | [What is the difference between setState and replaceState methods?](#what-is-the-difference-between-setstate-and-replacestate-methods) | +| 102 | [How to listen to state changes?](#how-to-listen-to-state-changes) | +| 103 | [What is the recommended approach of removing an array element in react state?](#what-is-the-recommended-approach-of-removing-an-array-element-in-react-state) | +| 104 | [Is it possible to use React without rendering HTML?](#is-it-possible-to-use-react-without-rendering-html) | +| 105 | [How to pretty print JSON with React?](#how-to-pretty-print-json-with-react) | +| 106 | [Why you can't update props in React?](#why-you-cant-update-props-in-react) | +| 107 | [How to focus an input element on page load?](#how-to-focus-an-input-element-on-page-load) | +| 108 | [What are the possible ways of updating objects in state?](#what-are-the-possible-ways-of-updating-objects-in-state) | +| 110 | [How can we find the version of React at runtime in the browser?](#how-can-we-find-the-version-of-react-at-runtime-in-the-browser) | +| 111 | [What are the approaches to include polyfills in your create-react-app?](#what-are-the-approaches-to-include-polyfills-in-your-create-react-app) | +| 112 | [How to use https instead of http in create-react-app?](#how-to-use-https-instead-of-http-in-create-react-app) | +| 113 | [How to avoid using relative path imports in create-react-app?](#how-to-avoid-using-relative-path-imports-in-create-react-app) | +| 114 | [How to add Google Analytics for react-router?](#how-to-add-google-analytics-for-react-router) | +| 115 | [How to update a component every second?](#how-to-update-a-component-every-second) | +| 116 | [How do you apply vendor prefixes to inline styles in React?](#how-do-you-apply-vendor-prefixes-to-inline-styles-in-react) | +| 117 | [How to import and export components using react and ES6?](#how-to-import-and-export-components-using-react-and-es6) | +| 118 | [What are the exceptions on React component naming?](#what-are-the-exceptions-on-react-component-naming) | +| 119 | [Why is a component constructor called only once?](#why-is-a-component-constructor-called-only-once) | +| 120 | [How to define constants in React?](#how-to-define-constants-in-react) | +| 121 | [How to programmatically trigger click event in React?](#how-to-programmatically-trigger-click-event-in-react) | +| 122 | [Is it possible to use async/await in plain React?](#is-it-possible-to-use-asyncawait-in-plain-react) | +| 123 | [What are the common folder structures for React?](#what-are-the-common-folder-structures-for-react) | +| 124 | [What are the popular packages for animation?](#what-are-the-popular-packages-for-animation) | +| 125 | [What is the benefit of styles modules?](#what-is-the-benefit-of-styles-modules) | +| 126 | [What are the popular React-specific linters?](#what-are-the-popular-react-specific-linters) | +| 127 | [How to make AJAX call and In which component lifecycle methods should I make an AJAX call?](#how-to-make-ajax-call-and-in-which-component-lifecycle-methods-should-i-make-an-ajax-call) | +| 128 | [What are render props?](#what-are-render-props) | +| | **React Router** | +| 129 | [What is React Router?](#what-is-react-router) | +| 130 | [How React Router is different from history library?](#how-react-router-is-different-from-history-library) | +| 131 | [What are the \ components of React Router v4?](#what-are-the-router-components-of-react-router-v4) | +| 132 | [What is the purpose of push and replace methods of history?](#what-is-the-purpose-of-push-and-replace-methods-of-history) | +| 133 | [How do you programmatically navigate using React router v4?](#how-do-you-programmatically-navigate-using-react-router-v4) | +| 134 | [How to get query parameters in React Router v4](#how-to-get-query-parameters-in-react-router-v4) | +| 135 | [Why you get "Router may have only one child element" warning?](#why-you-get-router-may-have-only-one-child-element-warning) | +| 136 | [How to pass params to history.push method in React Router v4?](#how-to-pass-params-to-historypush-method-in-react-router-v4) | +| 137 | [How to implement default or NotFound page?](#how-to-implement-default-or-notfound-page) | +| 138 | [How to get history on React Router v4?](#how-to-get-history-on-react-router-v4) | +| 139 | [How to perform automatic redirect after login?](#how-to-perform-automatic-redirect-after-login) | +| | **React Internationalization** | +| 140 | [What is React-Intl?](#what-is-react-intl) | +| 141 | [What are the main features of React Intl?](#what-are-the-main-features-of-react-intl) | +| 142 | [What are the two ways of formatting in React Intl?](#what-are-the-two-ways-of-formatting-in-react-intl) | +| 143 | [How to use FormattedMessage as placeholder using React Intl?](#how-to-use-formattedmessage-as-placeholder-using-react-intl) | +| 144 | [How to access current locale with React Intl](#how-to-access-current-locale-with-react-intl) | +| 145 | [How to format date using React Intl?](#how-to-format-date-using-react-intl) | +| | **React Testing** | +| 146 | [What is Shallow Renderer in React testing?](#what-is-shallow-renderer-in-react-testing) | +| 147 | [What is TestRenderer package in React?](#what-is-testrenderer-package-in-react) | +| 148 | [What is the purpose of ReactTestUtils package?](#what-is-the-purpose-of-reacttestutils-package) | +| 149 | [What is Jest?](#what-is-jest) | +| 150 | [What are the advantages of Jest over Jasmine?](#what-are-the-advantages-of-jest-over-jasmine) | +| 151 | [Give a simple example of Jest test case](#give-a-simple-example-of-jest-test-case) | +| | **React Redux** | +| 152 | [What is Flux?](#what-is-flux) | +| 153 | [What is Redux?](#what-is-redux) | +| 154 | [What are the core principles of Redux?](#what-are-the-core-principles-of-redux) | +| 155 | [What are the downsides of Redux compared to Flux?](#what-are-the-downsides-of-redux-compared-to-flux) | +| 156 | [What is the difference between mapStateToProps() and mapDispatchToProps()?](#what-is-the-difference-between-mapstatetoprops-and-mapdispatchtoprops) | +| 157 | [Can I dispatch an action in reducer?](#can-i-dispatch-an-action-in-reducer) | +| 158 | [How to access Redux store outside a component?](#how-to-access-redux-store-outside-a-component) | +| 159 | [What are the drawbacks of MVW pattern](#what-are-the-drawbacks-of-mvw-pattern) | +| 160 | [Are there any similarities between Redux and RxJS?](#are-there-any-similarities-between-redux-and-rxjs) | +| 161 | [How to dispatch an action on load?](#how-to-dispatch-an-action-on-load) | +| 162 | [How to use connect from React Redux?](#how-to-use-connect-from-react-redux) | +| 163 | [How to reset state in Redux?](#how-to-reset-state-in-redux) | +| 164 | [Whats the purpose of at symbol in the redux connect decorator?](#whats-the-purpose-of-at-symbol-in-the-redux-connect-decorator) | +| 165 | [What is the difference between React context and React Redux?](#what-is-the-difference-between-react-context-and-react-redux) | +| 166 | [Why are Redux state functions called reducers?](#why-are-redux-state-functions-called-reducers) | +| 167 | [How to make AJAX request in Redux?](#how-to-make-ajax-request-in-redux) | +| 168 | [Should I keep all component's state in Redux store?](#should-i-keep-all-components-state-in-redux-store) | +| 169 | [What is the proper way to access Redux store?](#what-is-the-proper-way-to-access-redux-store) | +| 170 | [What is the difference between component and container in React Redux?](#what-is-the-difference-between-component-and-container-in-react-redux) | +| 171 | [What is the purpose of the constants in Redux? ](#what-is-the-purpose-of-the-constants-in-redux) | +| 172 | [What are the different ways to write mapDispatchToProps()?](#what-are-the-different-ways-to-write-mapdispatchtoprops) | +| 173 | [What is the use of the ownProps parameter in mapStateToProps() and mapDispatchToProps()?](#what-is-the-use-of-the-ownprops-parameter-in-mapstatetoprops-and-mapdispatchtoprops) | +| 174 | [How to structure Redux top level directories?](#how-to-structure-redux-top-level-directories) | +| 175 | [What is redux-saga?](#what-is-redux-saga) | +| 176 | [What is the mental model of redux-saga?](#what-is-the-mental-model-of-redux-saga) | +| 177 | [What are the differences between call and put in redux-saga](#what-are-the-differences-between-call-and-put-in-redux-saga) | +| 178 | [What is Redux Thunk?](#what-is-redux-thunk) | +| 179 | [What are the differences between redux-saga and redux-thunk](#what-are-the-differences-between-redux-saga-and-redux-thunk) | +| 180 | [What is Redux DevTools?](#what-is-redux-devtools) | +| 181 | [What are the features of Redux DevTools?](#what-are-the-features-of-redux-devtools) | +| 182 | [What are Redux selectors and Why to use them?](#what-are-redux-selectors-and-why-to-use-them) | +| 183 | [What is Redux Form?](#what-is-redux-form) | +| 184 | [What are the main features of Redux Form?](#what-are-the-main-features-of-redux-form) | +| 185 | [How to add multiple middlewares to Redux?](#how-to-add-multiple-middlewares-to-redux) | +| 186 | [How to set initial state in Redux?](#how-to-set-initial-state-in-redux) | +| 187 | [How Relay is different from Redux?](#how-relay-is-different-from-redux) | +| 188 | [What is an action in Redux?](#what-is-an-action-in-redux) | +| | **React Native** | +| 188 | [What is the difference between React Native and React?](#what-is-the-difference-between-react-native-and-react) | +| 189 | [How to test React Native apps?](#how-to-test-react-native-apps) | +| 190 | [How to do logging in React Native?](#how-to-do-logging-in-react-native) | +| 191 | [How to debug your React Native?](#how-to-debug-your-react-native) | +| | **React supported libraries and Integration** | +| 192 | [What is reselect and how it works?](#what-is-reselect-and-how-it-works) | +| 193 | [What is Flow?](#what-is-flow) | +| 194 | [What is the difference between Flow and PropTypes?](#what-is-the-difference-between-flow-and-proptypes) | +| 195 | [How to use font-awesome icons in React?](#how-to-use-font-awesome-icons-in-react) | +| 196 | [What is React Dev Tools?](#what-is-react-dev-tools) | +| 197 | [Why is DevTools not loading in Chrome for local files?](#why-is-devtools-not-loading-in-chrome-for-local-files) | +| 198 | [How to use Polymer in React?](#how-to-use-polymer-in-react) | +| 199 | [What are the advantages of React over Vue.js?](#what-are-the-advantages-of-react-over-vuejs) | +| 200 | [What is the difference between React and Angular?](#what-is-the-difference-between-react-and-angular) | +| 201 | [Why React tab is not showing up in DevTools?](#why-react-tab-is-not-showing-up-in-devtools) | +| 202 | [What are styled components?](#what-are-styled-components) | +| 203 | [Give an example of Styled Components?](#give-an-example-of-styled-components) | +| 204 | [What is Relay?](#what-is-relay) | +| 205 | [How to use TypeScript in create-react-app application?](#how-to-use-typescript-in-create-react-app-application) | +| | **Miscellaneous** | +| 206 | [What are the main features of reselect library?](#what-are-the-main-features-of-reselect-library) | +| 207 | [Give an example of reselect usage?](#give-an-example-of-reselect-usage) | +| 209 | [Does the statics object work with ES6 classes in React?](#does-the-statics-object-work-with-es6-classes-in-react) | +| 210 | [Can Redux only be used with React?](#can-redux-only-be-used-with-react) | +| 211 | [Do you need to have a particular build tool to use Redux?](#do-you-need-to-have-a-particular-build-tool-to-use-redux) | +| 212 | [How Redux Form initialValues get updated from state?](#how-redux-form-initialvalues-get-updated-from-state) | +| 213 | [How React PropTypes allow different type for one prop?](#how-react-proptypes-allow-different-types-for-one-prop) | +| 214 | [Can I import an SVG file as react component?](#can-i-import-an-svg-file-as-react-component) | +| 215 | [Why are inline ref callbacks or functions not recommended?](#why-are-inline-ref-callbacks-or-functions-not-recommended) | +| 216 | [What is render hijacking in React?](#what-is-render-hijacking-in-react) | +| 217 | [What are HOC factory implementations?](#what-are-hoc-factory-implementations) | +| 218 | [How to pass numbers to React component?](#how-to-pass-numbers-to-react-component) | +| 219 | [Do I need to keep all my state into Redux? Should I ever use react internal state?](#do-i-need-to-keep-all-my-state-into-redux-should-i-ever-use-react-internal-state) | +| 220 | [What is the purpose of registerServiceWorker in React?](#what-is-the-purpose-of-registerserviceworker-in-react) | +| 221 | [What is React memo function?](#what-is-react-memo-function) | +| 222 | [What is React lazy function?](#what-is-react-lazy-function) | +| 223 | [How to prevent unnecessary updates using setState?](#how-to-prevent-unnecessary-updates-using-setstate) | +| 224 | [How do you render Array, Strings and Numbers in React 16 Version?](#how-do-you-render-array-strings-and-numbers-in-react-16-version) | +| 225 | [How to use class field declarations syntax in React classes?](#how-to-use-class-field-declarations-syntax-in-react-classes) | +| 226 | [What are hooks?](#what-are-hooks) | +| 227 | [What rules need to be followed for hooks?](#what-rules-need-to-be-followed-for-hooks) | +| 228 | [How to ensure hooks followed the rules in your project?](#how-to-ensure-hooks-followed-the-rules-in-your-project) | +| 229 | [What are the differences between Flux and Redux?](#what-are-the-differences-between-flux-and-redux) | +| 230 | [What are the benefits of React Router V4?](#what-are-the-benefits-of-react-router-v4) | +| 231 | [Can you describe about componentDidCatch lifecycle method signature?](#can-you-describe-about-componentdidcatch-lifecycle-method-signature) | +| 232 | [In which scenarios error boundaries do not catch errors?](#in-which-scenarios-error-boundaries-do-not-catch-errors) | +| 233 | [Why do you not need error boundaries for event handlers?](#why-do-you-not-need-error-boundaries-for-event-handlers) | +| 234 | [What is the difference between try catch block and error boundaries?](#what-is-the-difference-between-try-catch-block-and-error-boundaries) | +| 235 | [What is the behavior of uncaught errors in react 16?](#what-is-the-behavior-of-uncaught-errors-in-react-16) | +| 236 | [What is the proper placement for error boundaries?](#what-is-the-proper-placement-for-error-boundaries) | +| 237 | [What is the benefit of component stack trace from error boundary?](#what-is-the-benefit-of-component-stack-trace-from-error-boundary) | +| 238 | [What is the required method to be defined for a class component?](#what-is-the-required-method-to-be-defined-for-a-class-component) | +| 239 | [What are the possible return types of render method?](#what-are-the-possible-return-types-of-render-method) | +| 240 | [What is the main purpose of constructor?](#what-is-the-main-purpose-of-constructor) | +| 241 | [Is it mandatory to define constructor for React component?](#is-it-mandatory-to-define-constructor-for-react-component) | +| 242 | [What are default props?](#what-are-default-props) | +| 243 | [Why should not call setState in componentWillUnmount?](#why-should-not-call-setstate-in-componentwillunmount) | +| 244 | [What is the purpose of getDerivedStateFromError?](#what-is-the-purpose-of-getderivedstatefromerror) | +| 245 | [What is the methods order when component re-rendered?](#what-is-the-methods-order-when-component-re-rendered) | +| 246 | [What are the methods invoked during error handling?](#what-are-the-methods-invoked-during-error-handling) | +| 247 | [What is the purpose of displayName class property?](#what-is-the-purpose-of-displayname-class-property) | +| 248 | [What is the browser support for react applications?](#what-is-the-browser-support-for-react-applications) | +| 249 | [What is the purpose of unmountComponentAtNode method?](#what-is-the-purpose-of-unmountcomponentatnode-method) | +| 250 | [What is code-splitting?](#what-is-code-splitting) | +| 251 | [What is the benefit of strict mode?](#what-is-the-benefit-of-strict-mode) | +| 252 | [What are Keyed Fragments?](#what-are-keyed-fragments) | +| 253 | [Does React support all HTML attributes?](#does-react-support-all-html-attributes) | +| 254 | [What are the limitations with HOCs?](#what-are-the-limitations-with-hocs) | +| 255 | [How to debug forwardRefs in DevTools?](#how-to-debug-forwardrefs-in-devtools) | +| 256 | [When component props defaults to true?](#when-component-props-defaults-to-true) | +| 257 | [What is NextJS and major features of it?](#what-is-nextjs-and-major-features-of-it) | +| 258 | [How do you pass an event handler to a component?](#how-do-you-pass-an-event-handler-to-a-component) | +| 259 | [Is it good to use arrow functions in render methods?](#is-it-good-to-use-arrow-functions-in-render-methods) | +| 260 | [How to prevent a function from being called multiple times?](#how-to-prevent-a-function-from-being-called-multiple-times) | +| 261 | [How JSX prevents Injection Attacks?](#how-jsx-prevents-injection-attacks) | +| 262 | [How do you update rendered elements?](#how-do-you-update-rendered-elements) | +| 263 | [How do you say that props are read only?](#how-do-you-say-that-props-are-read-only) | +| 264 | [How do you say that state updates are merged?](#how-do-you-say-that-state-updates-are-merged) | +| 265 | [How do you pass arguments to an event handler?](#how-do-you-pass-arguments-to-an-event-handler) | +| 266 | [How to prevent component from rendering?](#how-to-prevent-component-from-rendering) | +| 267 | [What are the conditions to safely use the index as a key?](#what-are-the-conditions-to-safely-use-the-index-as-a-key) | +| 268 | [Is it keys should be globally unique?](#is-it-keys-should-be-globally-unique) | +| 269 | [What is the popular choice for form handling?](#what-is-the-popular-choice-for-form-handling) | +| 270 | [What are the advantages of formik over redux form library?](#what-are-the-advantages-of-formik-over-redux-form-library) | +| 271 | [Why do you not required to use inheritance?](#why-do-you-not-required-to-use-inheritance) | +| 272 | [Can I use web components in react application?](#can-i-use-web-components-in-react-application) | +| 273 | [What is dynamic import?](#what-is-dynamic-import) | +| 274 | [What are loadable components?](#what-are-loadable-components) | +| 275 | [What is suspense component?](#what-is-suspense-component) | +| 276 | [What is route based code splitting?](#what-is-route-based-code-splitting) | +| 277 | [Give an example on How to use context?](#give-an-example-on-how-to-use-context) | +| 278 | [What is the purpose of default value in context?](#what-is-the-purpose-of-default-value-in-context) | +| 279 | [How do you use contextType?](#how-do-you-use-contexttype) | +| 280 | [What is a consumer?](#what-is-a-consumer) | +| 281 | [How do you solve performance corner cases while using context?](#how-do-you-solve-performance-corner-cases-while-using-context) | +| 282 | [What is the purpose of forward ref in HOCs?](#what-is-the-purpose-of-forward-ref-in-hocs) | +| 283 | [Is it ref argument available for all functions or class components?](#is-it-ref-argument-available-for-all-functions-or-class-components) | +| 284 | [Why do you need additional care for component libraries while using forward refs?](#why-do-you-need-additional-care-for-component-libraries-while-using-forward-refs) | +| 285 | [How to create react class components without ES6?](#how-to-create-react-class-components-without-es6) | +| 286 | [Is it possible to use react without JSX?](#is-it-possible-to-use-react-without-jsx) | +| 287 | [What is diffing algorithm?](#what-is-diffing-algorithm) | +| 288 | [What are the rules covered by diffing algorithm?](#what-are-the-rules-covered-by-diffing-algorithm) | +| 289 | [When do you need to use refs?](#when-do-you-need-to-use-refs) | +| 290 | [Is it prop must be named as render for render props?](#is-it-prop-must-be-named-as-render-for-render-props) | +| 291 | [What are the problems of using render props with pure components?](#what-are-the-problems-of-using-render-props-with-pure-components) | +| 292 | [How do you create HOC using render props?](#how-do-you-create-hoc-using-render-props) | +| 293 | [What is windowing technique?](#what-is-windowing-technique) | +| 294 | [How do you print falsy values in JSX?](#how-do-you-print-falsy-values-in-jsx) | +| 295 | [What is the typical use case of portals?](#what-is-the-typical-use-case-of-portals) | +| 296 | [How do you set default value for uncontrolled component?](#how-do-you-set-default-value-for-uncontrolled-component) | +| 297 | [What is your favorite React stack?](#what-is-your-favorite-react-stack) | +| 298 | [What is the difference between Real DOM and Virtual DOM?](#what-is-the-difference-between-real-dom-and-virtual-dom) | +| 299 | [How to add Bootstrap to a react application?](#how-to-add-bootstrap-to-a-react-application) | +| 300 | [Can you list down top websites or applications using react as front end framework?](#can-you-list-down-top-websites-or-applications-using-react-as-front-end-framework) | +| 301 | [Is it recommended to use CSS In JS technique in React?](#is-it-recommended-to-use-css-in-js-technique-in-react) | +| 302 | [Do I need to rewrite all my class components with hooks?](#do-i-need-to-rewrite-all-my-class-components-with-hooks) | +| 303 | [How to fetch data with React Hooks?](#how-to-fetch-data-with-react-hooks) | +| 304 | [Is Hooks cover all use cases for classes?](#is-hooks-cover-all-use-cases-for-classes) | +| 305 | [What is the stable release for hooks support?](#what-is-the-stable-release-for-hooks-support) | +| 306 | [Why do we use array destructuring (square brackets notation) in useState?](#why-do-we-use-array-destructuring-square-brackets-notation-in-usestate) | +| 307 | [What are the sources used for introducing hooks?](#what-are-the-sources-used-for-introducing-hooks) | +| 308 | [How do you access imperative API of web components?](#how-do-you-access-imperative-api-of-web-components) | +| 309 | [What is formik?](#what-is-formik) | +| 310 | [What are typical middleware choices for handling asynchronous calls in Redux?](#what-are-typical-middleware-choices-for-handling-asynchronous-calls-in-redux) | +| 311 | [Do browsers understand JSX code?](#do-browsers-understand-jsx-code) | +| 312 | [Describe about data flow in react?](#describe-about-data-flow-in-react) | +| 313 | [What is react scripts?](#what-is-react-scripts) | +| 314 | [What are the features of create react app?](#what-are-the-features-of-create-react-app) | +| 315 | [What is the purpose of renderToNodeStream method?](#what-is-the-purpose-of-rendertonodestream-method) | +| 316 | [What is MobX?](#what-is-mobx) | +| 317 | [What are the differences between Redux and MobX?](#what-are-the-differences-between-redux-and-mobx) | +| 318 | [Should I learn ES6 before learning ReactJS?](#should-i-learn-es6-before-learning-reactjs) | +| 319 | [What is Concurrent Rendering?](#what-is-concurrent-rendering) | +| 320 | [What is the difference between async mode and concurrent mode?](#what-is-the-difference-between-async-mode-and-concurrent-mode) | +| 321 | [Can I use javascript urls in react16.9?](#can-i-use-javascript-urls-in-react169) | +| 322 | [What is the purpose of eslint plugin for hooks?](#what-is-the-purpose-of-eslint-plugin-for-hooks) | +| 323 | [What is the difference between Imperative and Declarative in React?](#what-is-the-difference-between-imperative-and-declarative-in-react) | +| 324 | [What are the benefits of using typescript with reactjs?](#what-are-the-benefits-of-using-typescript-with-reactjs) | +| 325 | [How do you make sure that user remains authenticated on page refresh while using Context API State Management?](#how-do-you-make-sure-that-user-remains-authenticated-on-page-refresh-while-using-context-api-state-management) | +| 326 | [What are the benefits of new JSX transform?](#what-are-the-benefits-of-new-jsx-transform) | +| 327 | [How is the new JSX transform different from old transform?](#how-is-the-new-jsx-transform-different-from-old-transform) | +| 328 | [How do you get redux scaffolding using create-react-app?](#how-do-you-get-redux-scaffolding-using-create-react-app) | +| 329 | [What are React Server components?](#what-are-react-server-components) | +| 330 | [What is prop drilling?](#what-is-prop-drilling) | +| 331 | [What is state mutation and how to prevent it?](#what-is-state-mutation-and-how-to-prevent-it) | +| 332 | [What is the difference between useState and useRef hook?](#what-is-the-difference-between-usestate-and-useref-hook) | +| 333 | [What are the Differences Between Functional and Class Component in React](#what-are-the-differences-between-functional-and-class-component-in-react) | + +## Core React + +1. ### What is React? + + React is an **open-source front-end JavaScript library** that is used for building user interfaces, especially for single-page applications. It is used for handling view layer for web and mobile apps. React was created by [Jordan Walke](https://github.com/jordwalke), a software engineer working for Facebook. React was first deployed on Facebook's News Feed in 2011 and on Instagram in 2012. + + **[⬆ Back to Top](#table-of-contents)** + +2. ### What are the major features of React? + + The major features of React are: + + - It uses **VirtualDOM** instead of RealDOM considering that RealDOM manipulations are expensive. + - Supports **server-side rendering**. + - Follows **Unidirectional** data flow or data binding. + - Uses **reusable/composable** UI components to develop the view. + + **[⬆ Back to Top](#table-of-contents)** + +3. ### What is JSX? + + _JSX_ is a XML-like syntax extension to ECMAScript (the acronym stands for _JavaScript XML_). Basically it just provides syntactic sugar for the `React.createElement()` function, giving us expressiveness of JavaScript along with HTML like template syntax. + + In the example below text inside `

` tag is returned as JavaScript function to the render function. + + ```jsx harmony + export default function App() { + return ( +
+

{"Welcome to React world!"}

+
+ ); + } + ``` + +
See Class +

+ + ```jsx harmony + class App extends React.Component { + render() { + return ( +

+

{"Welcome to React world!"}

+
+ ); + } + } + ``` + +

+
+ + **Note:** JSX is stricter than HTML + + **[⬆ Back to Top](#table-of-contents)** + +4. ### What is the difference between Element and Component? + + An _Element_ is a plain object describing what you want to appear on the screen in terms of the DOM nodes or other components. _Elements_ can contain other _Elements_ in their props. Creating a React element is cheap. Once an element is created, it is never mutated. + + The object representation of React Element would be as follows: + + ```javascript + const element = React.createElement("div", { id: "login-btn" }, "Login"); + ``` + + The above `React.createElement()` function returns an object: + + ``` + { + type: 'div', + props: { + children: 'Login', + id: 'login-btn' + } + } + ``` + + And finally it renders to the DOM using `ReactDOM.render()`: + + ```html +
Login
+ ``` + + Whereas a **component** can be declared in several different ways. It can be a class with a `render()` method or it can be defined as a function. In either case, it takes props as an input, and returns a JSX tree as the output: + + ```javascript + const Button = ({ onLogin }) => ( +
+ Login +
+ ); + ``` + + Then JSX gets transpiled to a `React.createElement()` function tree: + + ```javascript + const Button = ({ onLogin }) => + React.createElement( + "div", + { id: "login-btn", onClick: onLogin }, + "Login" + ); + ``` + + **[⬆ Back to Top](#table-of-contents)** + +5. ### How to create components in React? + + There are two possible ways to create a component. + + 1. **Function Components:** This is the simplest way to create a component. Those are pure JavaScript functions that accept props object as the first parameter and return React elements: + + ```jsx harmony + function Greeting({ message }) { + return

{`Hello, ${message}`}

; + } + ``` + + 2. **Class Components:** You can also use ES6 class to define a component. The above function component can be written as: + + ```jsx harmony + class Greeting extends React.Component { + render() { + return

{`Hello, ${this.props.message}`}

; + } + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +6. ### When to use a Class Component over a Function Component? + + If the component needs _state or lifecycle methods_ then use class component otherwise use function component. + _However, from React 16.8 with the addition of Hooks, you could use state , lifecycle methods and other features that were only available in class component right in your function component._ + _So, it is always recommended to use Function components, unless you need a React functionality whose Function component equivalent is not present yet, like Error Boundaries _ + + **[⬆ Back to Top](#table-of-contents)** + +7. ### What are Pure Components? + + _`React.PureComponent`_ is exactly the same as _`React.Component`_ except that it handles the `shouldComponentUpdate()` method for you. When props or state changes, _PureComponent_ will do a shallow comparison on both props and state. _Component_ on the other hand won't compare current props and state to next out of the box. Thus, the component will re-render by default whenever `shouldComponentUpdate` is called. In functional componenets we use `React.memo()` API. `React.memo()` is a higher-order component. It takes a React component as its first argument and returns a special type of React component that allows the renderer to render the component while memoizing the output. Therefore, if the component’s props are shallowly equal, the `React.memo()` component will bail out the updates. + + **[⬆ Back to Top](#table-of-contents)** + +8. ### What is state in React? + + _State_ of a component is an object that holds some information that may change over the lifetime of the component. We should always try to make our state as simple as possible and minimize the number of stateful components. + + Let's create a user component with message state, + + ```jsx harmony + class User extends React.Component { + constructor(props) { + super(props); + + this.state = { + message: "Welcome to React world", + }; + } + + render() { + return ( +
+

{this.state.message}

+
+ ); + } + } + ``` + + ![state](images/state.jpg) + + State is similar to props, but it is private and fully controlled by the component ,i.e., it is not accessible to any other component till the owner component decides to pass it. + + **[⬆ Back to Top](#table-of-contents)** + +9. ### What are props in React? + + _Props_ are inputs to components. They are single values or objects containing a set of values that are passed to components on creation using a naming convention similar to HTML-tag attributes. They are data passed down from a parent component to a child component. + + The primary purpose of props in React is to provide following component functionality: + + 1. Pass custom data to your component. + 2. Trigger state changes. + 3. Use via `this.props.reactProp` inside component's `render()` method. + + For example, let us create an element with `reactProp` property: + + ```jsx harmony + + ``` + + This `reactProp` (or whatever you came up with) name then becomes a property attached to React's native props object which originally already exists on all components created using React library. + + ``` + props.reactProp + ``` + + **Example: Props in Class Based Component** + + ```jsx + import React from "react"; + import ReactDOM from "react-dom"; + + class ChildComponent extends React.Component { + render() { + return ( +
+

{this.props.name}

+

{this.props.age}

+
+ ); + } + } + + class ParentComponent extends React.Component { + render() { + return ( +
+ + +
+ ); + } + } + ``` + + **Example: Props in Functional Component** + + ```jsx + import React from "react"; + import ReactDOM from "react-dom"; + + const ChildComponent = (props) => { + return ( +
+

{props.name}

+

{props.age}

+
+ ); + }; + + const ParentComponent = () => { + return ( +
+ + +
+ ); + }; + ``` + + **[⬆ Back to Top](#table-of-contents)** + +10. ### What is the difference between state and props? + + Both _props_ and _state_ are plain JavaScript objects. While both of them hold information that influences the output of render, they are different in their functionality with respect to component. Props get passed to the component similar to function parameters whereas state is managed within the component similar to variables declared within a function. + + **[⬆ Back to Top](#table-of-contents)** + +11. ### Why should we not update the state directly? + + If you try to update the state directly then it won't re-render the component. + + ```javascript + //Wrong + this.state.message = "Hello world"; + ``` + + Instead use `setState()` method. It schedules an update to a component's state object. When state changes, the component responds by re-rendering. + + ```javascript + //Correct + this.setState({ message: "Hello World" }); + ``` + + **Note:** You can directly assign to the state object either in _constructor_ or using latest javascript's class field declaration syntax. + + **[⬆ Back to Top](#table-of-contents)** + +12. ### What is the purpose of callback function as an argument of `setState()`? + + The callback function is invoked when setState finished and the component gets rendered. Since `setState()` is **asynchronous** the callback function is used for any post action. + + **Note:** It is recommended to use lifecycle method rather than this callback function. + + ```javascript + setState({ name: "John" }, () => + console.log("The name has updated and component re-rendered") + ); + ``` + + **[⬆ Back to Top](#table-of-contents)** + +13. ### What is the difference between HTML and React event handling? + + Below are some of the main differences between HTML and React event handling, + + 1. In HTML, the event name usually represents in _lowercase_ as a convention: + + ```html + + ``` + + Whereas in React it follows _camelCase_ convention: + + ```jsx harmony + ; + } + } + ``` + + 2. **Public class fields syntax:** If you don't like to use bind approach then _public class fields syntax_ can be used to correctly bind callbacks. + + ```jsx harmony + handleClick = () => { + console.log("this is:", this); + }; + ``` + + ```jsx harmony + + ``` + + 3. **Arrow functions in callbacks:** You can use _arrow functions_ directly in the callbacks. + + ```jsx harmony + handleClick() { + console.log('Click happened'); + } + render() { + return ; + } + ``` + + **Note:** If the callback is passed as prop to child components, those components might do an extra re-rendering. In those cases, it is preferred to go with `.bind()` or _public class fields syntax_ approach considering performance. + + **[⬆ Back to Top](#table-of-contents)** + +15. ### How to pass a parameter to an event handler or callback? + + You can use an _arrow function_ to wrap around an _event handler_ and pass parameters: + + ```jsx harmony + + )); + + // Create ref to the DOM button: + const ref = React.createRef(); + {"Forward Ref"}; + ``` + + **[⬆ Back to Top](#table-of-contents)** + +22. ### Which is preferred option with in callback refs and findDOMNode()? + + It is preferred to use _callback refs_ over `findDOMNode()` API. Because `findDOMNode()` prevents certain improvements in React in the future. + + The **legacy** approach of using `findDOMNode`: + + ```javascript + class MyComponent extends Component { + componentDidMount() { + findDOMNode(this).scrollIntoView(); + } + + render() { + return
; + } + } + ``` + + The recommended approach is: + + ```javascript + class MyComponent extends Component { + constructor(props) { + super(props); + this.node = createRef(); + } + componentDidMount() { + this.node.current.scrollIntoView(); + } + + render() { + return
; + } + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +23. ### Why are String Refs legacy? + + If you worked with React before, you might be familiar with an older API where the `ref` attribute is a string, like `ref={'textInput'}`, and the DOM node is accessed as `this.refs.textInput`. We advise against it because _string refs have below issues_, and are considered legacy. String refs were **removed in React v16**. + + 1. They _force React to keep track of currently executing component_. This is problematic because it makes react module stateful, and thus causes weird errors when react module is duplicated in the bundle. + 2. They are _not composable_ — if a library puts a ref on the passed child, the user can't put another ref on it. Callback refs are perfectly composable. + 3. They _don't work with static analysis_ like Flow. Flow can't guess the magic that framework does to make the string ref appear on `this.refs`, as well as its type (which could be different). Callback refs are friendlier to static analysis. + 4. It doesn't work as most people would expect with the "render callback" pattern (e.g. ) + + ```jsx harmony + class MyComponent extends Component { + renderRow = (index) => { + // This won't work. Ref will get attached to DataTable rather than MyComponent: + return ; + + // This would work though! Callback refs are awesome. + return (this["input-" + index] = input)} />; + }; + + render() { + return ( + + ); + } + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +24. ### What is Virtual DOM? + + The _Virtual DOM_ (VDOM) is an in-memory representation of _Real DOM_. The representation of a UI is kept in memory and synced with the "real" DOM. It's a step that happens between the render function being called and the displaying of elements on the screen. This entire process is called _reconciliation_. + + **[⬆ Back to Top](#table-of-contents)** + +25. ### How Virtual DOM works? + + The _Virtual DOM_ works in three simple steps. + + 1. Whenever any underlying data changes, the entire UI is re-rendered in Virtual DOM representation. + + ![vdom](images/vdom1.png) + + 2. Then the difference between the previous DOM representation and the new one is calculated. + + ![vdom2](images/vdom2.png) + + 3. Once the calculations are done, the real DOM will be updated with only the things that have actually changed. + + ![vdom3](images/vdom3.png) + + **[⬆ Back to Top](#table-of-contents)** + +26. ### What is the difference between Shadow DOM and Virtual DOM? + + The _Shadow DOM_ is a browser technology designed primarily for scoping variables and CSS in _web components_. The _Virtual DOM_ is a concept implemented by libraries in JavaScript on top of browser APIs. + + **[⬆ Back to Top](#table-of-contents)** + +27. ### What is React Fiber? + + Fiber is the new _reconciliation_ engine or reimplementation of core algorithm in React v16. The goal of React Fiber is to increase its suitability for areas like animation, layout, gestures, ability to pause, abort, or reuse work and assign priority to different types of updates; and new concurrency primitives. + + **[⬆ Back to Top](#table-of-contents)** + +28. ### What is the main goal of React Fiber? + + The goal of _React Fiber_ is to increase its suitability for areas like animation, layout, and gestures. Its headline feature is **incremental rendering**: the ability to split rendering work into chunks and spread it out over multiple frames. + + _from documentation_ + + Its main goals are: + + 1. Ability to split interruptible work in chunks. + 2. Ability to prioritize, rebase and reuse work in progress. + 3. Ability to yield back and forth between parents and children to support layout in React. + 4. Ability to return multiple elements from render(). + 5. Better support for error boundaries. + + **[⬆ Back to Top](#table-of-contents)** + +29. ### What are controlled components? + + A component that controls the input elements within the forms on subsequent user input is called **Controlled Component**, i.e, every state mutation will have an associated handler function. + + For example, to write all the names in uppercase letters, we use handleChange as below, + + ```javascript + handleChange(event) { + this.setState({value: event.target.value.toUpperCase()}) + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +30. ### What are uncontrolled components? + + The **Uncontrolled Components** are the ones that store their own state internally, and you query the DOM using a ref to find its current value when you need it. This is a bit more like traditional HTML. + + In the below UserProfile component, the `name` input is accessed using ref. + + ```jsx harmony + class UserProfile extends React.Component { + constructor(props) { + super(props); + this.handleSubmit = this.handleSubmit.bind(this); + this.input = React.createRef(); + } + + handleSubmit(event) { + alert("A name was submitted: " + this.input.current.value); + event.preventDefault(); + } + + render() { + return ( +
+ + +
+ ); + } + } + ``` + + In most cases, it's recommend to use controlled components to implement forms. In a controlled component, form data is handled by a React component. The alternative is uncontrolled components, where form data is handled by the DOM itself. + + **[⬆ Back to Top](#table-of-contents)** + +31. ### What is the difference between createElement and cloneElement? + + JSX elements will be transpiled to `React.createElement()` functions to create React elements which are going to be used for the object representation of UI. Whereas `cloneElement` is used to clone an element and pass it new props. + + **[⬆ Back to Top](#table-of-contents)** + +32. ### What is Lifting State Up in React? + + When several components need to share the same changing data then it is recommended to _lift the shared state up_ to their closest common ancestor. That means if two child components share the same data from its parent, then move the state to parent instead of maintaining local state in both of the child components. + + **[⬆ Back to Top](#table-of-contents)** + +33. ### What are the different phases of component lifecycle? + + The component lifecycle has three distinct lifecycle phases: + + 1. **Mounting:** The component is ready to mount in the browser DOM. This phase covers initialization from `constructor()`, `getDerivedStateFromProps()`, `render()`, and `componentDidMount()` lifecycle methods. + + 2. **Updating:** In this phase, the component gets updated in two ways, sending the new props and updating the state either from `setState()` or `forceUpdate()`. This phase covers `getDerivedStateFromProps()`, `shouldComponentUpdate()`, `render()`, `getSnapshotBeforeUpdate()` and `componentDidUpdate()` lifecycle methods. + + 3. **Unmounting:** In this last phase, the component is not needed and gets unmounted from the browser DOM. This phase includes `componentWillUnmount()` lifecycle method. + + It's worth mentioning that React internally has a concept of phases when applying changes to the DOM. They are separated as follows + + 1. **Render** The component will render without any side effects. This applies to Pure components and in this phase, React can pause, abort, or restart the render. + + 2. **Pre-commit** Before the component actually applies the changes to the DOM, there is a moment that allows React to read from the DOM through the `getSnapshotBeforeUpdate()`. + + 3. **Commit** React works with the DOM and executes the final lifecycles respectively `componentDidMount()` for mounting, `componentDidUpdate()` for updating, and `componentWillUnmount()` for unmounting. + + React 16.3+ Phases (or an [interactive version](http://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/)) + + ![phases 16.4+](images/phases16.4.png) + + Before React 16.3 + + ![phases 16.2](images/phases.png) + + **[⬆ Back to Top](#table-of-contents)** + +34. ### What are the lifecycle methods of React? + + Before React 16.3 + + - **componentWillMount:** Executed before rendering and is used for App level configuration in your root component. + - **componentDidMount:** Executed after first rendering and here all AJAX requests, DOM or state updates, and set up event listeners should occur. + - **componentWillReceiveProps:** Executed when particular prop updates to trigger state transitions. + - **shouldComponentUpdate:** Determines if the component will be updated or not. By default it returns `true`. If you are sure that the component doesn't need to render after state or props are updated, you can return false value. It is a great place to improve performance as it allows you to prevent a re-render if component receives new prop. + - **componentWillUpdate:** Executed before re-rendering the component when there are props & state changes confirmed by `shouldComponentUpdate()` which returns true. + - **componentDidUpdate:** Mostly it is used to update the DOM in response to prop or state changes. + - **componentWillUnmount:** It will be used to cancel any outgoing network requests, or remove all event listeners associated with the component. + + React 16.3+ + + - **getDerivedStateFromProps:** Invoked right before calling `render()` and is invoked on _every_ render. This exists for rare use cases where you need a derived state. Worth reading [if you need derived state](https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html). + - **componentDidMount:** Executed after first rendering and where all AJAX requests, DOM or state updates, and set up event listeners should occur. + - **shouldComponentUpdate:** Determines if the component will be updated or not. By default, it returns `true`. If you are sure that the component doesn't need to render after the state or props are updated, you can return a false value. It is a great place to improve performance as it allows you to prevent a re-render if component receives a new prop. + - **getSnapshotBeforeUpdate:** Executed right before rendered output is committed to the DOM. Any value returned by this will be passed into `componentDidUpdate()`. This is useful to capture information from the DOM i.e. scroll position. + - **componentDidUpdate:** Mostly it is used to update the DOM in response to prop or state changes. This will not fire if `shouldComponentUpdate()` returns `false`. + - **componentWillUnmount** It will be used to cancel any outgoing network requests, or remove all event listeners associated with the component. + + **[⬆ Back to Top](#table-of-contents)** + +35. ### What are Higher-Order Components? + + A _higher-order component_ (_HOC_) is a function that takes a component and returns a new component. Basically, it's a pattern that is derived from React's compositional nature. + + We call them **pure components** because they can accept any dynamically provided child component but they won't modify or copy any behavior from their input components. + + ```javascript + const EnhancedComponent = higherOrderComponent(WrappedComponent); + ``` + + HOC can be used for many use cases: + + 1. Code reuse, logic and bootstrap abstraction. + 2. Render hijacking. + 3. State abstraction and manipulation. + 4. Props manipulation. + + **[⬆ Back to Top](#table-of-contents)** + +36. ### How to create props proxy for HOC component? + + You can add/edit props passed to the component using _props proxy_ pattern like this: + + ```jsx harmony + function HOC(WrappedComponent) { + return class Test extends Component { + render() { + const newProps = { + title: "New Header", + footer: false, + showFeatureX: false, + showFeatureY: true, + }; + + return ; + } + }; + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +37. ### What is context? + + _Context_ provides a way to pass data through the component tree without having to pass props down manually at every level. + + For example, authenticated users, locale preferences, UI themes need to be accessed in the application by many components. + + ```javascript + const { Provider, Consumer } = React.createContext(defaultValue); + ``` + + **[⬆ Back to Top](#table-of-contents)** + +38. ### What is children prop? + + _Children_ is a prop (`this.props.children`) that allows you to pass components as data to other components, just like any other prop you use. Component tree put between component's opening and closing tag will be passed to that component as `children` prop. + + There are several methods available in the React API to work with this prop. These include `React.Children.map`, `React.Children.forEach`, `React.Children.count`, `React.Children.only`, `React.Children.toArray`. + + A simple usage of children prop looks as below, + + ```jsx harmony + const MyDiv = React.createClass({ + render: function () { + return
{this.props.children}
; + }, + }); + + ReactDOM.render( + + {"Hello"} + {"World"} + , + node + ); + ``` + + **[⬆ Back to Top](#table-of-contents)** + +39. ### How to write comments in React? + + The comments in React/JSX are similar to JavaScript Multiline comments but are wrapped in curly braces. + + **Single-line comments:** + + ```jsx harmony +
+ {/* Single-line comments(In vanilla JavaScript, the single-line comments are represented by double slash(//)) */} + {`Welcome ${user}, let's play React`} +
+ ``` + + **Multi-line comments:** + + ```jsx harmony +
+ {/* Multi-line comments for more than + one line */} + {`Welcome ${user}, let's play React`} +
+ ``` + + **[⬆ Back to Top](#table-of-contents)** + +40. ### What is the purpose of using super constructor with props argument? + + A child class constructor cannot make use of `this` reference until the `super()` method has been called. The same applies to ES6 sub-classes as well. The main reason for passing props parameter to `super()` call is to access `this.props` in your child constructors. + + **Passing props:** + + ```javascript + class MyComponent extends React.Component { + constructor(props) { + super(props); + + console.log(this.props); // prints { name: 'John', age: 42 } + } + } + ``` + + **Not passing props:** + + ```javascript + class MyComponent extends React.Component { + constructor(props) { + super(); + + console.log(this.props); // prints undefined + + // but props parameter is still available + console.log(props); // prints { name: 'John', age: 42 } + } + + render() { + // no difference outside constructor + console.log(this.props); // prints { name: 'John', age: 42 } + } + } + ``` + + The above code snippets reveals that `this.props` is different only within the constructor. It would be the same outside the constructor. + + **[⬆ Back to Top](#table-of-contents)** + +41. ### What is reconciliation? + + When a component's props or state change, React decides whether an actual DOM update is necessary by comparing the newly returned element with the previously rendered one. When they are not equal, React will update the DOM. This process is called _reconciliation_. + + **[⬆ Back to Top](#table-of-contents)** + +42. ### How to set state with a dynamic key name? + + If you are using ES6 or the Babel transpiler to transform your JSX code then you can accomplish this with _computed property names_. + + ```javascript + handleInputChange(event) { + this.setState({ [event.target.id]: event.target.value }) + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +43. ### What would be the common mistake of function being called every time the component renders? + + You need to make sure that function is not being called while passing the function as a parameter. + + ```jsx harmony + render() { + // Wrong: handleClick is called instead of passed as a reference! + return + } + ``` + + Instead, pass the function itself without parenthesis: + + ```jsx harmony + render() { + // Correct: handleClick is passed as a reference! + return + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +44. ### Is lazy function supports named exports? + + No, currently `React.lazy` function supports default exports only. If you would like to import modules which are named exports, you can create an intermediate module that reexports it as the default. It also ensures that tree shaking keeps working and don’t pull unused components. + Let's take a component file which exports multiple named components, + + ```javascript + // MoreComponents.js + export const SomeComponent = /* ... */; + export const UnusedComponent = /* ... */; + ``` + + and reexport `MoreComponents.js` components in an intermediate file `IntermediateComponent.js` + + ```javascript + // IntermediateComponent.js + export { SomeComponent as default } from "./MoreComponents.js"; + ``` + + Now you can import the module using lazy function as below, + + ```javascript + import React, { lazy } from "react"; + const SomeComponent = lazy(() => import("./IntermediateComponent.js")); + ``` + + **[⬆ Back to Top](#table-of-contents)** + +45. ### Why React uses `className` over `class` attribute? + + `class` is a keyword in JavaScript, and JSX is an extension of JavaScript. That's the principal reason why React uses `className` instead of `class`. Pass a string as the `className` prop. + + ```jsx harmony + render() { + return {'Menu'} + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +46. ### What are fragments? + + It's a common pattern in React which is used for a component to return multiple elements. _Fragments_ let you group a list of children without adding extra nodes to the DOM. + + ```jsx harmony + render() { + return ( + + + + + + ) + } + ``` + + There is also a _shorter syntax_, but it's not supported in many tools: + + ```jsx harmony + render() { + return ( + <> + + + + + ) + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +47. ### Why fragments are better than container divs? + + Below are the list of reasons, + + 1. Fragments are a bit faster and use less memory by not creating an extra DOM node. This only has a real benefit on very large and deep trees. + 2. Some CSS mechanisms like _Flexbox_ and _CSS Grid_ have a special parent-child relationships, and adding divs in the middle makes it hard to keep the desired layout. + 3. The DOM Inspector is less cluttered. + + **[⬆ Back to Top](#table-of-contents)** + +48. ### What are portals in React? + + _Portal_ is a recommended way to render children into a DOM node that exists outside the DOM hierarchy of the parent component. + + ```javascript + ReactDOM.createPortal(child, container); + ``` + + The first argument is any render-able React child, such as an element, string, or fragment. The second argument is a DOM element. + + **[⬆ Back to Top](#table-of-contents)** + +49. ### What are stateless components? + + If the behaviour of a component is independent of its state then it can be a stateless component. You can use either a function or a class for creating stateless components. But unless you need to use a lifecycle hook in your components, you should go for function components. There are a lot of benefits if you decide to use function components here; they are easy to write, understand, and test, a little faster, and you can avoid the `this` keyword altogether. + + **[⬆ Back to Top](#table-of-contents)** + +50. ### What are stateful components? + + If the behaviour of a component is dependent on the _state_ of the component then it can be termed as stateful component. These _stateful components_ are always _class components_ and have a state that gets initialized in the `constructor`. + + ```javascript + class App extends Component { + constructor(props) { + super(props); + this.state = { count: 0 }; + } + + render() { + // ... + } + } + ``` + + **React 16.8 Update:** + + Hooks let you use state and other React features without writing classes. + + _The Equivalent Functional Component_ + + ```javascript + import React, {useState} from 'react'; + + const App = (props) => { + const [count, setCount] = useState(0); + + return ( + // JSX + ) + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +51. ### How to apply validation on props in React? + + When the application is running in _development mode_, React will automatically check all props that we set on components to make sure they have _correct type_. If the type is incorrect, React will generate warning messages in the console. It's disabled in _production mode_ due to performance impact. The mandatory props are defined with `isRequired`. + + The set of predefined prop types: + + 1. `PropTypes.number` + 2. `PropTypes.string` + 3. `PropTypes.array` + 4. `PropTypes.object` + 5. `PropTypes.func` + 6. `PropTypes.node` + 7. `PropTypes.element` + 8. `PropTypes.bool` + 9. `PropTypes.symbol` + 10. `PropTypes.any` + + We can define `propTypes` for `User` component as below: + + ```jsx harmony + import React from "react"; + import PropTypes from "prop-types"; + + class User extends React.Component { + static propTypes = { + name: PropTypes.string.isRequired, + age: PropTypes.number.isRequired, + }; + + render() { + return ( + <> +

{`Welcome, ${this.props.name}`}

+

{`Age, ${this.props.age}`}

+ + ); + } + } + ``` + + **Note:** In React v15.5 _PropTypes_ were moved from `React.PropTypes` to `prop-types` library. + + _The Equivalent Functional Component_ + + ```jsx harmony + import React from "react"; + import PropTypes from "prop-types"; + + function User({ name, age }) { + return ( + <> +

{`Welcome, ${name}`}

+

{`Age, ${age}`}

+ + ); + } + + User.propTypes = { + name: PropTypes.string.isRequired, + age: PropTypes.number.isRequired, + }; + ``` + + **[⬆ Back to Top](#table-of-contents)** + +52. ### What are the advantages of React? + + Below are the list of main advantages of React, + + 1. Increases the application's performance with _Virtual DOM_. + 2. JSX makes code easy to read and write. + 3. It renders both on client and server side (_SSR_). + 4. Easy to integrate with frameworks (Angular, Backbone) since it is only a view library. + 5. Easy to write unit and integration tests with tools such as Jest. + + **[⬆ Back to Top](#table-of-contents)** + +53. ### What are the limitations of React? + + Apart from the advantages, there are few limitations of React too, + + 1. React is just a view library, not a full framework. + 2. There is a learning curve for beginners who are new to web development. + 3. Integrating React into a traditional MVC framework requires some additional configuration. + 4. The code complexity increases with inline templating and JSX. + 5. Too many smaller components leading to over engineering or boilerplate. + + **[⬆ Back to Top](#table-of-contents)** + +54. ### What are error boundaries in React v16? + + _Error boundaries_ are components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of the component tree that crashed. + + A class component becomes an error boundary if it defines a new lifecycle method called `componentDidCatch(error, info)` or `static getDerivedStateFromError() `: + + ```jsx harmony + class ErrorBoundary extends React.Component { + constructor(props) { + super(props); + this.state = { hasError: false }; + } + + componentDidCatch(error, info) { + // You can also log the error to an error reporting service + logErrorToMyService(error, info); + } + + static getDerivedStateFromError(error) { + // Update state so the next render will show the fallback UI. + return { hasError: true }; + } + + render() { + if (this.state.hasError) { + // You can render any custom fallback UI + return

{"Something went wrong."}

; + } + return this.props.children; + } + } + ``` + + After that use it as a regular component: + + ```jsx harmony + + + + ``` + + **[⬆ Back to Top](#table-of-contents)** + +55. ### How are error boundaries handled in React v15? + + React v15 provided very basic support for _error boundaries_ using `unstable_handleError` method. It has been renamed to `componentDidCatch` in React v16. + + **[⬆ Back to Top](#table-of-contents)** + +56. ### What are the recommended ways for static type checking? + + Normally we use _PropTypes library_ (`React.PropTypes` moved to a `prop-types` package since React v15.5) for _type checking_ in the React applications. For large code bases, it is recommended to use _static type checkers_ such as Flow or TypeScript, that perform type checking at compile time and provide auto-completion features. + + **[⬆ Back to Top](#table-of-contents)** + +57. ### What is the use of `react-dom` package? + + The `react-dom` package provides _DOM-specific methods_ that can be used at the top level of your app. Most of the components are not required to use this module. Some of the methods of this package are: + + 1. `render()` + 2. `hydrate()` + 3. `unmountComponentAtNode()` + 4. `findDOMNode()` + 5. `createPortal()` + + **[⬆ Back to Top](#table-of-contents)** + +58. ### What is the purpose of render method of `react-dom`? + + This method is used to render a React element into the DOM in the supplied container and return a reference to the component. If the React element was previously rendered into container, it will perform an update on it and only mutate the DOM as necessary to reflect the latest changes. + + ``` + ReactDOM.render(element, container, [callback]) + ``` + + If the optional callback is provided, it will be executed after the component is rendered or updated. + + **[⬆ Back to Top](#table-of-contents)** + +59. ### What is ReactDOMServer? + + The `ReactDOMServer` object enables you to render components to static markup (typically used on node server). This object is mainly used for _server-side rendering_ (SSR). The following methods can be used in both the server and browser environments: + + 1. `renderToString()` + 2. `renderToStaticMarkup()` + + For example, you generally run a Node-based web server like Express, Hapi, or Koa, and you call `renderToString` to render your root component to a string, which you then send as response. + + ```javascript + // using Express + import { renderToString } from "react-dom/server"; + import MyPage from "./MyPage"; + + app.get("/", (req, res) => { + res.write( + "My Page" + ); + res.write('
'); + res.write(renderToString()); + res.write("
"); + res.end(); + }); + ``` + + **[⬆ Back to Top](#table-of-contents)** + +60. ### How to use innerHTML in React? + + The `dangerouslySetInnerHTML` attribute is React's replacement for using `innerHTML` in the browser DOM. Just like `innerHTML`, it is risky to use this attribute considering cross-site scripting (XSS) attacks. You just need to pass a `__html` object as key and HTML text as value. + + In this example MyComponent uses `dangerouslySetInnerHTML` attribute for setting HTML markup: + + ```jsx harmony + function createMarkup() { + return { __html: "First · Second" }; + } + + function MyComponent() { + return
; + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +61. ### How to use styles in React? + + The `style` attribute accepts a JavaScript object with camelCased properties rather than a CSS string. This is consistent with the DOM style JavaScript property, is more efficient, and prevents XSS security holes. + + ```jsx harmony + const divStyle = { + color: "blue", + backgroundImage: "url(" + imgUrl + ")", + }; + + function HelloWorldComponent() { + return
Hello World!
; + } + ``` + + Style keys are camelCased in order to be consistent with accessing the properties on DOM nodes in JavaScript (e.g. `node.style.backgroundImage`). + + **[⬆ Back to Top](#table-of-contents)** + +62. ### How events are different in React? + + Handling events in React elements has some syntactic differences: + + 1. React event handlers are named using camelCase, rather than lowercase. + 2. With JSX you pass a function as the event handler, rather than a string. + + **[⬆ Back to Top](#table-of-contents)** + +63. ### What will happen if you use `setState()` in constructor? + + When you use `setState()`, then apart from assigning to the object state React also re-renders the component and all its children. You would get error like this: _Can only update a mounted or mounting component._ So we need to use `this.state` to initialize variables inside constructor. + + **[⬆ Back to Top](#table-of-contents)** + +64. ### What is the impact of indexes as keys? + + Keys should be stable, predictable, and unique so that React can keep track of elements. + + In the below code snippet each element's key will be based on ordering, rather than tied to the data that is being represented. This limits the optimizations that React can do. + + ```jsx harmony + { + todos.map((todo, index) => ); + } + ``` + + If you use element data for unique key, assuming todo.id is unique to this list and stable, React would be able to reorder elements without needing to reevaluate them as much. + + ```jsx harmony + { + todos.map((todo) => ); + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +65. ### Is it good to use `setState()` in `componentWillMount()` method? + + Yes, it is safe to use `setState()` inside `componentWillMount()` method. But at the same it is recommended to avoid async initialization in `componentWillMount()` lifecycle method. `componentWillMount()` is invoked immediately before mounting occurs. It is called before `render()`, therefore setting state in this method will not trigger a re-render. Avoid introducing any side-effects or subscriptions in this method. We need to make sure async calls for component initialization happened in `componentDidMount()` instead of `componentWillMount()`. + + ```jsx harmony + componentDidMount() { + axios.get(`api/todos`) + .then((result) => { + this.setState({ + messages: [...result.data] + }) + }) + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +66. ### What will happen if you use props in initial state? + + If the props on the component are changed without the component being refreshed, the new prop value will never be displayed because the constructor function will never update the current state of the component. The initialization of state from props only runs when the component is first created. + + The below component won't display the updated input value: + + ```jsx harmony + class MyComponent extends React.Component { + constructor(props) { + super(props); + + this.state = { + records: [], + inputValue: this.props.inputValue, + }; + } + + render() { + return
{this.state.inputValue}
; + } + } + ``` + + Using props inside render method will update the value: + + ```jsx harmony + class MyComponent extends React.Component { + constructor(props) { + super(props); + + this.state = { + record: [], + }; + } + + render() { + return
{this.props.inputValue}
; + } + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +67. ### How do you conditionally render components? + + In some cases you want to render different components depending on some state. JSX does not render `false` or `undefined`, so you can use conditional _short-circuiting_ to render a given part of your component only if a certain condition is true. + + ```jsx harmony + const MyComponent = ({ name, address }) => ( +
+

{name}

+ {address &&

{address}

} +
+ ); + ``` + + If you need an `if-else` condition then use _ternary operator_. + + ```jsx harmony + const MyComponent = ({ name, address }) => ( +
+

{name}

+ {address ?

{address}

:

{"Address is not available"}

} +
+ ); + ``` + + **[⬆ Back to Top](#table-of-contents)** + +68. ### Why we need to be careful when spreading props on DOM elements? + + When we _spread props_ we run into the risk of adding unknown HTML attributes, which is a bad practice. Instead we can use prop destructuring with `...rest` operator, so it will add only required props. + + For example, + + ```jsx harmony + const ComponentA = () => ( + + ); + + const ComponentB = ({ isDisplay, ...domProps }) => ( +
{"ComponentB"}
+ ); + ``` + + **[⬆ Back to Top](#table-of-contents)** + +69. ### How you use decorators in React? + + You can _decorate_ your _class_ components, which is the same as passing the component into a function. **Decorators** are flexible and readable way of modifying component functionality. + + ```jsx harmony + @setTitle("Profile") + class Profile extends React.Component { + //.... + } + + /* + title is a string that will be set as a document title + WrappedComponent is what our decorator will receive when + put directly above a component class as seen in the example above + */ + const setTitle = (title) => (WrappedComponent) => { + return class extends React.Component { + componentDidMount() { + document.title = title; + } + + render() { + return ; + } + }; + }; + ``` + + **Note:** Decorators are a feature that didn't make it into ES7, but are currently a _stage 2 proposal_. + + **[⬆ Back to Top](#table-of-contents)** + +70. ### How do you memoize a component? + + There are memoize libraries available which can be used on function components. + + For example `moize` library can memoize the component in another component. + + ```jsx harmony + import moize from "moize"; + import Component from "./components/Component"; // this module exports a non-memoized component + + const MemoizedFoo = moize.react(Component); + + const Consumer = () => { +
+ {"I will memoize the following entry:"} + +
; + }; + ``` + + **Update:** Since React v16.6.0, we have a `React.memo`. It provides a higher order component which memoizes component unless the props change. To use it, simply wrap the component using React.memo before you use it. + + ```js + const MemoComponent = React.memo(function MemoComponent(props) { + /* render using props */ + }); + OR; + export default React.memo(MyFunctionComponent); + ``` + + **[⬆ Back to Top](#table-of-contents)** + +71. ### How you implement Server Side Rendering or SSR? + + React is already equipped to handle rendering on Node servers. A special version of the DOM renderer is available, which follows the same pattern as on the client side. + + ```jsx harmony + import ReactDOMServer from "react-dom/server"; + import App from "./App"; + + ReactDOMServer.renderToString(); + ``` + + This method will output the regular HTML as a string, which can be then placed inside a page body as part of the server response. On the client side, React detects the pre-rendered content and seamlessly picks up where it left off. + + **[⬆ Back to Top](#table-of-contents)** + +72. ### How to enable production mode in React? + + You should use Webpack's `DefinePlugin` method to set `NODE_ENV` to `production`, by which it strip out things like propType validation and extra warnings. Apart from this, if you minify the code, for example, Uglify's dead-code elimination to strip out development only code and comments, it will drastically reduce the size of your bundle. + + **[⬆ Back to Top](#table-of-contents)** + +73. ### What is CRA and its benefits? + + The `create-react-app` CLI tool allows you to quickly create & run React applications with no configuration step. + + Let's create Todo App using _CRA_: + + ```console + # Installation + $ npm install -g create-react-app + + # Create new project + $ create-react-app todo-app + $ cd todo-app + + # Build, test and run + $ npm run build + $ npm run test + $ npm start + ``` + + It includes everything we need to build a React app: + + 1. React, JSX, ES6, and Flow syntax support. + 2. Language extras beyond ES6 like the object spread operator. + 3. Autoprefixed CSS, so you don’t need -webkit- or other prefixes. + 4. A fast interactive unit test runner with built-in support for coverage reporting. + 5. A live development server that warns about common mistakes. + 6. A build script to bundle JS, CSS, and images for production, with hashes and sourcemaps. + + **[⬆ Back to Top](#table-of-contents)** + +74. ### What is the lifecycle methods order in mounting? + + The lifecycle methods are called in the following order when an instance of a component is being created and inserted into the DOM. + + 1. `constructor()` + 2. `static getDerivedStateFromProps()` + 3. `render()` + 4. `componentDidMount()` + + **[⬆ Back to Top](#table-of-contents)** + +75. ### What are the lifecycle methods going to be deprecated in React v16? + + The following lifecycle methods going to be unsafe coding practices and will be more problematic with async rendering. + + 1. `componentWillMount()` + 2. `componentWillReceiveProps()` + 3. `componentWillUpdate()` + + Starting with React v16.3 these methods are aliased with `UNSAFE_` prefix, and the unprefixed version will be removed in React v17. + + **[⬆ Back to Top](#table-of-contents)** + +76. ### What is the purpose of `getDerivedStateFromProps()` lifecycle method? + + The new static `getDerivedStateFromProps()` lifecycle method is invoked after a component is instantiated as well as before it is re-rendered. It can return an object to update state, or `null` to indicate that the new props do not require any state updates. + + ```javascript + class MyComponent extends React.Component { + static getDerivedStateFromProps(props, state) { + // ... + } + } + ``` + + This lifecycle method along with `componentDidUpdate()` covers all the use cases of `componentWillReceiveProps()`. + + **[⬆ Back to Top](#table-of-contents)** + +77. ### What is the purpose of `getSnapshotBeforeUpdate()` lifecycle method? + + The new `getSnapshotBeforeUpdate()` lifecycle method is called right before DOM updates. The return value from this method will be passed as the third parameter to `componentDidUpdate()`. + + ```javascript + class MyComponent extends React.Component { + getSnapshotBeforeUpdate(prevProps, prevState) { + // ... + } + } + ``` + + This lifecycle method along with `componentDidUpdate()` covers all the use cases of `componentWillUpdate()`. + + **[⬆ Back to Top](#table-of-contents)** + +78. ### Do Hooks replace render props and higher order components? + + Both render props and higher-order components render only a single child but in most of the cases Hooks are a simpler way to serve this by reducing nesting in your tree. + + **[⬆ Back to Top](#table-of-contents)** + +79. ### What is the recommended way for naming components? + + It is recommended to name the component by reference instead of using `displayName`. + + Using `displayName` for naming component: + + ```javascript + export default React.createClass({ + displayName: "TodoApp", + // ... + }); + ``` + + The **recommended** approach: + + ```javascript + export default class TodoApp extends React.Component { + // ... + } + ``` + + also + + ```javascript + const TodoApp = () => { + //... + }; + export default TodoApp; + ``` + + **[⬆ Back to Top](#table-of-contents)** + +80. ### What is the recommended ordering of methods in component class? + + _Recommended_ ordering of methods from _mounting_ to _render stage_: + + 1. `static` methods + 2. `constructor()` + 3. `getChildContext()` + 4. `componentWillMount()` + 5. `componentDidMount()` + 6. `componentWillReceiveProps()` + 7. `shouldComponentUpdate()` + 8. `componentWillUpdate()` + 9. `componentDidUpdate()` + 10. `componentWillUnmount()` + 11. click handlers or event handlers like `onClickSubmit()` or `onChangeDescription()` + 12. getter methods for render like `getSelectReason()` or `getFooterContent()` + 13. optional render methods like `renderNavigation()` or `renderProfilePicture()` + 14. `render()` + + **[⬆ Back to Top](#table-of-contents)** + +81. ### What is a switching component? + + A _switching component_ is a component that renders one of many components. We need to use object to map prop values to components. + + For example, a switching component to display different pages based on `page` prop: + + ```jsx harmony + import HomePage from "./HomePage"; + import AboutPage from "./AboutPage"; + import ServicesPage from "./ServicesPage"; + import ContactPage from "./ContactPage"; + + const PAGES = { + home: HomePage, + about: AboutPage, + services: ServicesPage, + contact: ContactPage, + }; + + const Page = (props) => { + const Handler = PAGES[props.page] || ContactPage; + + return ; + }; + + // The keys of the PAGES object can be used in the prop types to catch dev-time errors. + Page.propTypes = { + page: PropTypes.oneOf(Object.keys(PAGES)).isRequired, + }; + ``` + + **[⬆ Back to Top](#table-of-contents)** + +82. ### Why we need to pass a function to setState()? + + The reason behind for this is that `setState()` is an asynchronous operation. React batches state changes for performance reasons, so the state may not change immediately after `setState()` is called. That means you should not rely on the current state when calling `setState()` since you can't be sure what that state will be. The solution is to pass a function to `setState()`, with the previous state as an argument. By doing this you can avoid issues with the user getting the old state value on access due to the asynchronous nature of `setState()`. + + Let's say the initial count value is zero. After three consecutive increment operations, the value is going to be incremented only by one. + + ```javascript + // assuming this.state.count === 0 + this.setState({ count: this.state.count + 1 }); + this.setState({ count: this.state.count + 1 }); + this.setState({ count: this.state.count + 1 }); + // this.state.count === 1, not 3 + ``` + + If we pass a function to `setState()`, the count gets incremented correctly. + + ```javascript + this.setState((prevState, props) => ({ + count: prevState.count + props.increment, + })); + // this.state.count === 3 as expected + ``` + + **(OR)** + + ### Why function is preferred over object for `setState()`? + + React may batch multiple `setState()` calls into a single update for performance. Because `this.props` and `this.state` may be updated asynchronously, you should not rely on their values for calculating the next state. + + This counter example will fail to update as expected: + + ```javascript + // Wrong + this.setState({ + counter: this.state.counter + this.props.increment, + }); + ``` + + The preferred approach is to call `setState()` with function rather than object. That function will receive the previous state as the first argument, and the props at the time the update is applied as the second argument. + + ```javascript + // Correct + this.setState((prevState, props) => ({ + counter: prevState.counter + props.increment, + })); + ``` + + **[⬆ Back to Top](#table-of-contents)** + +83. ### What is strict mode in React? + + `React.StrictMode` is a useful component for highlighting potential problems in an application. Just like ``, `` does not render any extra DOM elements. It activates additional checks and warnings for its descendants. These checks apply for _development mode_ only. + + ```jsx harmony + import React from "react"; + + function ExampleApplication() { + return ( +
+
+ +
+ + +
+
+
+
+ ); + } + ``` + + In the example above, the _strict mode_ checks apply to `` and `` components only. + + **[⬆ Back to Top](#table-of-contents)** + +84. ### What are React Mixins? + + _Mixins_ are a way to totally separate components to have a common functionality. Mixins **should not be used** and can be replaced with _higher-order components_ or _decorators_. + + One of the most commonly used mixins is `PureRenderMixin`. You might be using it in some components to prevent unnecessary re-renders when the props and state are shallowly equal to the previous props and state: + + ```javascript + const PureRenderMixin = require("react-addons-pure-render-mixin"); + + const Button = React.createClass({ + mixins: [PureRenderMixin], + // ... + }); + ``` + + + + **[⬆ Back to Top](#table-of-contents)** + +85. ### Why is `isMounted()` an anti-pattern and what is the proper solution? + + The primary use case for `isMounted()` is to avoid calling `setState()` after a component has been unmounted, because it will emit a warning. + + ```javascript + if (this.isMounted()) { + this.setState({...}) + } + ``` + + Checking `isMounted()` before calling `setState()` does eliminate the warning, but it also defeats the purpose of the warning. Using `isMounted()` is a code smell because the only reason you would check is because you think you might be holding a reference after the component has unmounted. + + An optimal solution would be to find places where `setState()` might be called after a component has unmounted, and fix them. Such situations most commonly occur due to callbacks, when a component is waiting for some data and gets unmounted before the data arrives. Ideally, any callbacks should be canceled in `componentWillUnmount()`, prior to unmounting. + + **[⬆ Back to Top](#table-of-contents)** + +86. ### What are the Pointer Events supported in React? + + _Pointer Events_ provide a unified way of handling all input events. In the old days we had a mouse and respective event listeners to handle them but nowadays we have many devices which don't correlate to having a mouse, like phones with touch surface or pens. We need to remember that these events will only work in browsers that support the _Pointer Events_ specification. + + The following event types are now available in _React DOM_: + + 1. `onPointerDown` + 2. `onPointerMove` + 3. `onPointerUp` + 4. `onPointerCancel` + 5. `onGotPointerCapture` + 6. `onLostPointerCapture` + 7. `onPointerEnter` + 8. `onPointerLeave` + 9. `onPointerOver` + 10. `onPointerOut` + + **[⬆ Back to Top](#table-of-contents)** + +87. ### Why should component names start with capital letter? + + If you are rendering your component using JSX, the name of that component has to begin with a capital letter otherwise React will throw an error as an unrecognized tag. This convention is because only HTML elements and SVG tags can begin with a lowercase letter. + + ```jsx harmony + class SomeComponent extends Component { + // Code goes here + } + ``` + + You can define component class which name starts with lowercase letter, but when it's imported it should have capital letter. Here lowercase is fine: + + ```jsx harmony + class myComponent extends Component { + render() { + return
; + } + } + + export default myComponent; + ``` + + While when imported in another file it should start with capital letter: + + ```jsx harmony + import MyComponent from "./myComponent"; + ``` + + #### What are the exceptions on React component naming? + + The component names should start with an uppercase letter but there are few exceptions to this convention. The lowercase tag names with a dot (property accessors) are still considered as valid component names. + For example, the below tag can be compiled to a valid component, + + ```jsx harmony + render() { + return ( + // `React.createElement(obj.component)` + ) + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + +88. ### Are custom DOM attributes supported in React v16? + + Yes. In the past, React used to ignore unknown DOM attributes. If you wrote JSX with an attribute that React doesn't recognize, React would just skip it. + + For example, let's take a look at the below attribute: + + ```jsx harmony +
+ ``` + + Would render an empty div to the DOM with React v15: + + ```html +
+ ``` + + In React v16 any unknown attributes will end up in the DOM: + + ```html +
+ ``` + + This is useful for supplying browser-specific non-standard attributes, trying new DOM APIs, and integrating with opinionated third-party libraries. + + **[⬆ Back to Top](#table-of-contents)** + +89. ### What is the difference between constructor and getInitialState? + + You should initialize state in the constructor when using ES6 classes, and `getInitialState()` method when using `React.createClass()`. + + **Using ES6 classes:** + + ```javascript + class MyComponent extends React.Component { + constructor(props) { + super(props); + this.state = { + /* initial state */ + }; + } + } + ``` + + **Using `React.createClass()`:** + + ```javascript + const MyComponent = React.createClass({ + getInitialState() { + return { + /* initial state */ + }; + }, + }); + ``` + + **Note:** `React.createClass()` is deprecated and removed in React v16. Use plain JavaScript classes instead. + + **[⬆ Back to Top](#table-of-contents)** + +90. ### Can you force a component to re-render without calling setState? + + By default, when your component's state or props change, your component will re-render. If your `render()` method depends on some other data, you can tell React that the component needs re-rendering by calling `forceUpdate()`. + + ```javascript + component.forceUpdate(callback); + ``` + + It is recommended to avoid all uses of `forceUpdate()` and only read from `this.props` and `this.state` in `render()`. + + **[⬆ Back to Top](#table-of-contents)** + +91. ### What is the difference between `super()` and `super(props)` in React using ES6 classes? + + When you want to access `this.props` in `constructor()` then you should pass props to `super()` method. + + **Using `super(props)`:** + + ```javascript + class MyComponent extends React.Component { + constructor(props) { + super(props); + console.log(this.props); // { name: 'John', ... } + } + } + ``` + + **Using `super()`:** + + ```javascript + class MyComponent extends React.Component { + constructor(props) { + super(); + console.log(this.props); // undefined + } + } + ``` + + Outside `constructor()` both will display same value for `this.props`. + + **[⬆ Back to Top](#table-of-contents)** + +92. ### How to loop inside JSX? + + You can simply use `Array.prototype.map` with ES6 _arrow function_ syntax. + + For example, the `items` array of objects is mapped into an array of components: + + ```jsx harmony + + {items.map((item) => ( + + ))} + + ``` + + But you can't iterate using `for` loop: + + ```jsx harmony + + for (let i = 0; i < items.length; i++) { + + } + + ``` + + This is because JSX tags are transpiled into _function calls_, and you can't use statements inside expressions. This may change thanks to `do` expressions which are _stage 1 proposal_. + + **[⬆ Back to Top](#table-of-contents)** + +93. ### How do you access props in attribute quotes? + + React (or JSX) doesn't support variable interpolation inside an attribute value. The below representation won't work: + + ```jsx harmony + + ``` + + But you can put any JS expression inside curly braces as the entire attribute value. So the below expression works: + + ```jsx harmony + + ``` + + Using _template strings_ will also work: + + ```jsx harmony + + ``` + + **[⬆ Back to Top](#table-of-contents)** + +94. ### What is React proptype array with shape? + + If you want to pass an array of objects to a component with a particular shape then use `React.PropTypes.shape()` as an argument to `React.PropTypes.arrayOf()`. + + ```javascript + ReactComponent.propTypes = { + arrayWithShape: React.PropTypes.arrayOf( + React.PropTypes.shape({ + color: React.PropTypes.string.isRequired, + fontSize: React.PropTypes.number.isRequired, + }) + ).isRequired, + }; + ``` + + **[⬆ Back to Top](#table-of-contents)** + +95. ### How to conditionally apply class attributes? + + You shouldn't use curly braces inside quotes because it is going to be evaluated as a string. + + ```jsx harmony +
+ ``` + + Instead you need to move curly braces outside (don't forget to include spaces between class names): + + ```jsx harmony +
+ ``` + + _Template strings_ will also work: + + ```jsx harmony +
+ ``` + + **[⬆ Back to Top](#table-of-contents)** + +96. ### What is the difference between React and ReactDOM? + + The `react` package contains `React.createElement()`, `React.Component`, `React.Children`, and other helpers related to elements and component classes. You can think of these as the isomorphic or universal helpers that you need to build components. The `react-dom` package contains `ReactDOM.render()`, and in `react-dom/server` we have _server-side rendering_ support with `ReactDOMServer.renderToString()` and `ReactDOMServer.renderToStaticMarkup()`. + + **[⬆ Back to Top](#table-of-contents)** + +97. ### Why ReactDOM is separated from React? + + The React team worked on extracting all DOM-related features into a separate library called _ReactDOM_. React v0.14 is the first release in which the libraries are split. By looking at some of the packages, `react-native`, `react-art`, `react-canvas`, and `react-three`, it has become clear that the beauty and essence of React has nothing to do with browsers or the DOM. + + To build more environments that React can render to, React team planned to split the main React package into two: `react` and `react-dom`. This paves the way to writing components that can be shared between the web version of React and React Native. + + **[⬆ Back to Top](#table-of-contents)** + +98. ### How to use React label element? + + If you try to render a `
` tag so that the formatting of the `JSON.stringify()` is retained:
+
+     ```jsx harmony
+     const data = { name: "John", age: 42 };
+
+     class User extends React.Component {
+       render() {
+         return 
{JSON.stringify(data, null, 2)}
; + } + } + + React.render(, document.getElementById("container")); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +106. ### Why you can't update props in React? + + The React philosophy is that props should be _immutable_ and _top-down_. This means that a parent can send any prop values to a child, but the child can't modify received props. + +**[⬆ Back to Top](#table-of-contents)** + +107. ### How to focus an input element on page load? + + You can do it by creating _ref_ for `input` element and using it in `componentDidMount()`: + + ```jsx harmony + class App extends React.Component { + componentDidMount() { + this.nameInput.focus(); + } + + render() { + return ( +
+ + (this.nameInput = input)} + defaultValue={"Will focus"} + /> +
+ ); + } + } + + ReactDOM.render(, document.getElementById("app")); + ``` + + Also in Functional component (react 16.08 and above) + + ```jsx harmony + import React, { useEffect, useRef } from "react"; + + const App = () => { + const inputElRef = useRef(null); + + useEffect(() => { + inputElRef.current.focus(); + }, []); + + return ( +
+ + +
+ ); + }; + + ReactDOM.render(, document.getElementById("app")); + ``` + + **[⬆ Back to Top](#table-of-contents)** + +108. ### What are the possible ways of updating objects in state? + + 1. **Calling `setState()` with an object to merge with state:** + + - Using `Object.assign()` to create a copy of the object: + + ```javascript + const user = Object.assign({}, this.state.user, { age: 42 }); + this.setState({ user }); + ``` + + - Using _spread operator_: + + ```javascript + const user = { ...this.state.user, age: 42 }; + this.setState({ user }); + ``` + + 2. **Calling `setState()` with a function:** + + ```javascript + this.setState((prevState) => ({ + user: { + ...prevState.user, + age: 42, + }, + })); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +110. ### How can we find the version of React at runtime in the browser? + + You can use `React.version` to get the version. + + ```jsx harmony + const REACT_VERSION = React.version; + + ReactDOM.render( +
{`React version: ${REACT_VERSION}`}
, + document.getElementById("app") + ); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +111. ### What are the approaches to include polyfills in your `create-react-app`? + + There are approaches to include polyfills in create-react-app, + + 1. **Manual import from `core-js`:** + + Create a file called (something like) `polyfills.js` and import it into root `index.js` file. Run `npm install core-js` or `yarn add core-js` and import your specific required features. + + ```javascript + import "core-js/fn/array/find"; + import "core-js/fn/array/includes"; + import "core-js/fn/number/is-nan"; + ``` + + 2. **Using Polyfill service:** + + Use the polyfill.io CDN to retrieve custom, browser-specific polyfills by adding this line to `index.html`: + + ```html + + ``` + + In the above script we had to explicitly request the `Array.prototype.includes` feature as it is not included in the default feature set. + +**[⬆ Back to Top](#table-of-contents)** + +112. ### How to use https instead of http in create-react-app? + + You just need to use `HTTPS=true` configuration. You can edit your `package.json` scripts section: + + ```json + "scripts": { + "start": "set HTTPS=true && react-scripts start" + } + ``` + + or just run `set HTTPS=true && npm start` + +**[⬆ Back to Top](#table-of-contents)** + +113. ### How to avoid using relative path imports in create-react-app? + + Create a file called `.env` in the project root and write the import path: + + ``` + NODE_PATH=src/app + ``` + + After that restart the development server. Now you should be able to import anything inside `src/app` without relative paths. + +**[⬆ Back to Top](#table-of-contents)** + +114. ### How to add Google Analytics for React Router? + + Add a listener on the `history` object to record each page view: + + ```javascript + history.listen(function (location) { + window.ga("set", "page", location.pathname + location.search); + window.ga("send", "pageview", location.pathname + location.search); + }); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +115. ### How to update a component every second? + + You need to use `setInterval()` to trigger the change, but you also need to clear the timer when the component unmounts to prevent errors and memory leaks. + + ```javascript + componentDidMount() { + this.interval = setInterval(() => this.setState({ time: Date.now() }), 1000) + } + + componentWillUnmount() { + clearInterval(this.interval) + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +116. ### How do you apply vendor prefixes to inline styles in React? + + React _does not_ apply _vendor prefixes_ automatically. You need to add vendor prefixes manually. + + ```jsx harmony +
+ ``` + +**[⬆ Back to Top](#table-of-contents)** + +117. ### How to import and export components using React and ES6? + + You should use default for exporting the components + + ```jsx harmony + import React from "react"; + import User from "user"; + + export default class MyProfile extends React.Component { + render() { + return //...; + } + } + ``` + + With the export specifier, the MyProfile is going to be the member and exported to this module and the same can be imported without mentioning the name in other components. + +**[⬆ Back to Top](#table-of-contents)** + +119. ### Why is a component constructor called only once? + + React's _reconciliation_ algorithm assumes that without any information to the contrary, if a custom component appears in the same place on subsequent renders, it's the same component as before, so reuses the previous instance rather than creating a new one. + +**[⬆ Back to Top](#table-of-contents)** + +120. ### How to define constants in React? + + You can use ES7 `static` field to define constant. + + ```javascript + class MyComponent extends React.Component { + static DEFAULT_PAGINATION = 10; + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +121. ### How to programmatically trigger click event in React? + + You could use the ref prop to acquire a reference to the underlying `HTMLInputElement` object through a callback, store the reference as a class property, then use that reference to later trigger a click from your event handlers using the `HTMLElement.click` method. + + This can be done in two steps: + + 1. Create ref in render method: + + ```jsx harmony + (this.inputElement = input)} /> + ``` + + 2. Apply click event in your event handler: + + ```javascript + this.inputElement.click(); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +122. ### Is it possible to use async/await in plain React? + + If you want to use `async`/`await` in React, you will need _Babel_ and [transform-async-to-generator](https://babeljs.io/docs/en/babel-plugin-transform-async-to-generator) plugin. React Native ships with Babel and a set of transforms. + +**[⬆ Back to Top](#table-of-contents)** + +123. ### What are the common folder structures for React? + + There are two common practices for React project file structure. + + 1. **Grouping by features or routes:** + + One common way to structure projects is locate CSS, JS, and tests together, grouped by feature or route. + + ``` + common/ + ├─ Avatar.js + ├─ Avatar.css + ├─ APIUtils.js + └─ APIUtils.test.js + feed/ + ├─ index.js + ├─ Feed.js + ├─ Feed.css + ├─ FeedStory.js + ├─ FeedStory.test.js + └─ FeedAPI.js + profile/ + ├─ index.js + ├─ Profile.js + ├─ ProfileHeader.js + ├─ ProfileHeader.css + └─ ProfileAPI.js + ``` + + 2. **Grouping by file type:** + + Another popular way to structure projects is to group similar files together. + + ``` + api/ + ├─ APIUtils.js + ├─ APIUtils.test.js + ├─ ProfileAPI.js + └─ UserAPI.js + components/ + ├─ Avatar.js + ├─ Avatar.css + ├─ Feed.js + ├─ Feed.css + ├─ FeedStory.js + ├─ FeedStory.test.js + ├─ Profile.js + ├─ ProfileHeader.js + └─ ProfileHeader.css + ``` + +**[⬆ Back to Top](#table-of-contents)** + +124. ### What are the popular packages for animation? + + _React Transition Group_ and _React Motion_ are popular animation packages in React ecosystem. + +**[⬆ Back to Top](#table-of-contents)** + +125. ### What is the benefit of styles modules? + + It is recommended to avoid hard coding style values in components. Any values that are likely to be used across different UI components should be extracted into their own modules. + + For example, these styles could be extracted into a separate component: + + ```javascript + export const colors = { + white, + black, + blue, + }; + + export const space = [0, 8, 16, 32, 64]; + ``` + + And then imported individually in other components: + + ```javascript + import { space, colors } from "./styles"; + ``` + +**[⬆ Back to Top](#table-of-contents)** + +126. ### What are the popular React-specific linters? + + ESLint is a popular JavaScript linter. There are plugins available that analyse specific code styles. One of the most common for React is an npm package called `eslint-plugin-react`. By default, it will check a number of best practices, with rules checking things from keys in iterators to a complete set of prop types. + + Another popular plugin is `eslint-plugin-jsx-a11y`, which will help fix common issues with accessibility. As JSX offers slightly different syntax to regular HTML, issues with `alt` text and `tabindex`, for example, will not be picked up by regular plugins. + +**[⬆ Back to Top](#table-of-contents)** + +127. ### How to make AJAX call and in which component lifecycle methods should I make an AJAX call? + + You can use AJAX libraries such as Axios, jQuery AJAX, and the browser built-in `fetch`. You should fetch data in the `componentDidMount()` lifecycle method. This is so you can use `setState()` to update your component when the data is retrieved. + + For example, the employees list fetched from API and set local state: + + ```jsx harmony + class MyComponent extends React.Component { + constructor(props) { + super(props); + this.state = { + employees: [], + error: null, + }; + } + + componentDidMount() { + fetch("https://api.example.com/items") + .then((res) => res.json()) + .then( + (result) => { + this.setState({ + employees: result.employees, + }); + }, + (error) => { + this.setState({ error }); + } + ); + } + + render() { + const { error, employees } = this.state; + if (error) { + return
Error: {error.message}
; + } else { + return ( +
    + {employees.map((employee) => ( +
  • + {employee.name}-{employee.experience} +
  • + ))} +
+ ); + } + } + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +128. ### What are render props? + + **Render Props** is a simple technique for sharing code between components using a prop whose value is a function. The below component uses render prop which returns a React element. + + ```jsx harmony +

{`Hello ${data.target}`}

} /> + ``` + + Libraries such as React Router and DownShift are using this pattern. + +## React Router + +**[⬆ Back to Top](#table-of-contents)** + +129. ### What is React Router? + + React Router is a powerful routing library built on top of React that helps you add new screens and flows to your application incredibly quickly, all while keeping the URL in sync with what's being displayed on the page. + +**[⬆ Back to Top](#table-of-contents)** + +130. ### How React Router is different from history library? + + React Router is a wrapper around the `history` library which handles interaction with the browser's `window.history` with its browser and hash histories. It also provides memory history which is useful for environments that don't have global history, such as mobile app development (React Native) and unit testing with Node. + +**[⬆ Back to Top](#table-of-contents)** + +131. ### What are the `` components of React Router v4? + + React Router v4 provides below 3 `` components: + + 1. `` + 2. `` + 3. `` + + The above components will create _browser_, _hash_, and _memory_ history instances. React Router v4 makes the properties and methods of the `history` instance associated with your router available through the context in the `router` object. + +**[⬆ Back to Top](#table-of-contents)** + +132. ### What is the purpose of `push()` and `replace()` methods of `history`? + + A history instance has two methods for navigation purpose. + + 1. `push()` + 2. `replace()` + + If you think of the history as an array of visited locations, `push()` will add a new location to the array and `replace()` will replace the current location in the array with the new one. + +**[⬆ Back to Top](#table-of-contents)** + +133. ### How do you programmatically navigate using React Router v4? + + There are three different ways to achieve programmatic routing/navigation within components. + + 1. **Using the `withRouter()` higher-order function:** + + The `withRouter()` higher-order function will inject the history object as a prop of the component. This object provides `push()` and `replace()` methods to avoid the usage of context. + + ```jsx harmony + import { withRouter } from "react-router-dom"; // this also works with 'react-router-native' + + const Button = withRouter(({ history }) => ( + + )); + ``` + + 2. **Using `` component and render props pattern:** + + The `` component passes the same props as `withRouter()`, so you will be able to access the history methods through the history prop. + + ```jsx harmony + import { Route } from "react-router-dom"; + + const Button = () => ( + ( + + )} + /> + ); + ``` + + 3. **Using context:** + + This option is not recommended and treated as unstable API. + + ```jsx harmony + const Button = (props, context) => ( + + ); + + Button.contextTypes = { + history: React.PropTypes.shape({ + push: React.PropTypes.func.isRequired, + }), + }; + ``` + +**[⬆ Back to Top](#table-of-contents)** + +134. ### How to get query parameters in React Router v4? + + The ability to parse query strings was taken out of React Router v4 because there have been user requests over the years to support different implementation. So the decision has been given to users to choose the implementation they like. The recommended approach is to use query strings library. + + ```javascript + const queryString = require("query-string"); + const parsed = queryString.parse(props.location.search); + ``` + + You can also use `URLSearchParams` if you want something native: + + ```javascript + const params = new URLSearchParams(props.location.search); + const foo = params.get("name"); + ``` + + You should use a _polyfill_ for IE11. + +**[⬆ Back to Top](#table-of-contents)** + +135. ### Why you get "Router may have only one child element" warning? + + You have to wrap your Route's in a `` block because `` is unique in that it renders a route exclusively. + + At first you need to add `Switch` to your imports: + + ```javascript + import { Switch, Router, Route } from "react-router"; + ``` + + Then define the routes within `` block: + + ```jsx harmony + + + + + + + ``` + +**[⬆ Back to Top](#table-of-contents)** + +136. ### How to pass params to `history.push` method in React Router v4? + + While navigating you can pass props to the `history` object: + + ```javascript + this.props.history.push({ + pathname: "/template", + search: "?name=sudheer", + state: { detail: response.data }, + }); + ``` + + The `search` property is used to pass query params in `push()` method. + +**[⬆ Back to Top](#table-of-contents)** + +137. ### How to implement _default_ or _NotFound_ page? + + A `` renders the first child `` that matches. A `` with no path always matches. So you just need to simply drop path attribute as below + + ```jsx harmony + + + + + + ``` + +**[⬆ Back to Top](#table-of-contents)** + +138. ### How to get history on React Router v4? + + Below are the list of steps to get history object on React Router v4, + + 1. Create a module that exports a `history` object and import this module across the project. + + For example, create `history.js` file: + + ```javascript + import { createBrowserHistory } from "history"; + + export default createBrowserHistory({ + /* pass a configuration object here if needed */ + }); + ``` + + 2. You should use the `` component instead of built-in routers. Import the above `history.js` inside `index.js` file: + + ```jsx harmony + import { Router } from "react-router-dom"; + import history from "./history"; + import App from "./App"; + + ReactDOM.render( + + + , + holder + ); + ``` + + 3. You can also use push method of `history` object similar to built-in history object: + + ```javascript + // some-other-file.js + import history from "./history"; + + history.push("/go-here"); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +139. ### How to perform automatic redirect after login? + + The `react-router` package provides `` component in React Router. Rendering a `` will navigate to a new location. Like server-side redirects, the new location will override the current location in the history stack. + + ```javascript + import React, { Component } from "react"; + import { Redirect } from "react-router"; + + export default class LoginComponent extends Component { + render() { + if (this.state.isLoggedIn === true) { + return ; + } else { + return
{"Login Please"}
; + } + } + } + ``` + +## React Internationalization + +**[⬆ Back to Top](#table-of-contents)** + +140. ### What is React Intl? + + The _React Intl_ library makes internationalization in React straightforward, with off-the-shelf components and an API that can handle everything from formatting strings, dates, and numbers, to pluralization. React Intl is part of _FormatJS_ which provides bindings to React via its components and API. + +**[⬆ Back to Top](#table-of-contents)** + +141. ### What are the main features of React Intl? + + Below are the main features of React Intl, + + 1. Display numbers with separators. + 2. Display dates and times correctly. + 3. Display dates relative to "now". + 4. Pluralize labels in strings. + 5. Support for 150+ languages. + 6. Runs in the browser and Node. + 7. Built on standards. + +**[⬆ Back to Top](#table-of-contents)** + +142. ### What are the two ways of formatting in React Intl? + + The library provides two ways to format strings, numbers, and dates: + + 1. **Using react components:** + + ```jsx harmony + + ``` + + 2. **Using an API:** + + ```javascript + const messages = defineMessages({ + accountMessage: { + id: "account", + defaultMessage: "The amount is less than minimum balance.", + }, + }); + + formatMessage(messages.accountMessage); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +143. ### How to use `` as placeholder using React Intl? + + The `` components from `react-intl` return elements, not plain text, so they can't be used for placeholders, alt text, etc. In that case, you should use lower level API `formatMessage()`. You can inject the `intl` object into your component using `injectIntl()` higher-order component and then format the message using `formatMessage()` available on that object. + + ```jsx harmony + import React from "react"; + import { injectIntl, intlShape } from "react-intl"; + + const MyComponent = ({ intl }) => { + const placeholder = intl.formatMessage({ id: "messageId" }); + return ; + }; + + MyComponent.propTypes = { + intl: intlShape.isRequired, + }; + + export default injectIntl(MyComponent); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +144. ### How to access current locale with React Intl? + + You can get the current locale in any component of your application using `injectIntl()`: + + ```jsx harmony + import { injectIntl, intlShape } from "react-intl"; + + const MyComponent = ({ intl }) => ( +
{`The current locale is ${intl.locale}`}
+ ); + + MyComponent.propTypes = { + intl: intlShape.isRequired, + }; + + export default injectIntl(MyComponent); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +145. ### How to format date using React Intl? + + The `injectIntl()` higher-order component will give you access to the `formatDate()` method via the props in your component. The method is used internally by instances of `FormattedDate` and it returns the string representation of the formatted date. + + ```jsx harmony + import { injectIntl, intlShape } from "react-intl"; + + const stringDate = this.props.intl.formatDate(date, { + year: "numeric", + month: "numeric", + day: "numeric", + }); + + const MyComponent = ({ intl }) => ( +
{`The formatted date is ${stringDate}`}
+ ); + + MyComponent.propTypes = { + intl: intlShape.isRequired, + }; + + export default injectIntl(MyComponent); + ``` + +## React Testing + +**[⬆ Back to Top](#table-of-contents)** + +146. ### What is Shallow Renderer in React testing? + + _Shallow rendering_ is useful for writing unit test cases in React. It lets you render a component _one level deep_ and assert facts about what its render method returns, without worrying about the behavior of child components, which are not instantiated or rendered. + + For example, if you have the following component: + + ```javascript + function MyComponent() { + return ( +
+ {"Title"} + {"Description"} +
+ ); + } + ``` + + Then you can assert as follows: + + ```jsx harmony + import ShallowRenderer from "react-test-renderer/shallow"; + + // in your test + const renderer = new ShallowRenderer(); + renderer.render(); + + const result = renderer.getRenderOutput(); + + expect(result.type).toBe("div"); + expect(result.props.children).toEqual([ + {"Title"}, + {"Description"}, + ]); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +147. ### What is `TestRenderer` package in React? + + This package provides a renderer that can be used to render components to pure JavaScript objects, without depending on the DOM or a native mobile environment. This package makes it easy to grab a snapshot of the platform view hierarchy (similar to a DOM tree) rendered by a ReactDOM or React Native without using a browser or `jsdom`. + + ```jsx harmony + import TestRenderer from "react-test-renderer"; + + const Link = ({ page, children }) => {children}; + + const testRenderer = TestRenderer.create( + {"Facebook"} + ); + + console.log(testRenderer.toJSON()); + // { + // type: 'a', + // props: { href: 'https://www.facebook.com/' }, + // children: [ 'Facebook' ] + // } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +148. ### What is the purpose of ReactTestUtils package? + + _ReactTestUtils_ are provided in the `with-addons` package and allow you to perform actions against a simulated DOM for the purpose of unit testing. + +**[⬆ Back to Top](#table-of-contents)** + +149. ### What is Jest? + + _Jest_ is a JavaScript unit testing framework created by Facebook based on Jasmine and provides automated mock creation and a `jsdom` environment. It's often used for testing components. + +**[⬆ Back to Top](#table-of-contents)** + +150. ### What are the advantages of Jest over Jasmine? + + There are couple of advantages compared to Jasmine: + + - Automatically finds tests to execute in your source code. + - Automatically mocks dependencies when running your tests. + - Allows you to test asynchronous code synchronously. + - Runs your tests with a fake DOM implementation (via `jsdom`) so that your tests can be run on the command line. + - Runs tests in parallel processes so that they finish sooner. + +**[⬆ Back to Top](#table-of-contents)** + +151. ### Give a simple example of Jest test case + + Let's write a test for a function that adds two numbers in `sum.js` file: + + ```javascript + const sum = (a, b) => a + b; + + export default sum; + ``` + + Create a file named `sum.test.js` which contains actual test: + + ```javascript + import sum from "./sum"; + + test("adds 1 + 2 to equal 3", () => { + expect(sum(1, 2)).toBe(3); + }); + ``` + + And then add the following section to your `package.json`: + + ```json + { + "scripts": { + "test": "jest" + } + } + ``` + + Finally, run `yarn test` or `npm test` and Jest will print a result: + + ```console + $ yarn test + PASS ./sum.test.js + ✓ adds 1 + 2 to equal 3 (2ms) + ``` + +## React Redux + +**[⬆ Back to Top](#table-of-contents)** + +152. ### What is flux? + + _Flux_ is an _application design paradigm_ used as a replacement for the more traditional MVC pattern. It is not a framework or a library but a new kind of architecture that complements React and the concept of Unidirectional Data Flow. Facebook uses this pattern internally when working with React. + + The workflow between dispatcher, stores and views components with distinct inputs and outputs as follows: + + ![flux](images/flux.png) + +**[⬆ Back to Top](#table-of-contents)** + +153. ### What is Redux? + + _Redux_ is a predictable state container for JavaScript apps based on the _Flux design pattern_. Redux can be used together with React, or with any other view library. It is tiny (about 2kB) and has no dependencies. + +**[⬆ Back to Top](#table-of-contents)** + +154. ### What are the core principles of Redux? + + Redux follows three fundamental principles: + + 1. **Single source of truth:** The state of your whole application is stored in an object tree within a single store. The single state tree makes it easier to keep track of changes over time and debug or inspect the application. + 2. **State is read-only:** The only way to change the state is to emit an action, an object describing what happened. This ensures that neither the views nor the network callbacks will ever write directly to the state. + 3. **Changes are made with pure functions:** To specify how the state tree is transformed by actions, you write reducers. Reducers are just pure functions that take the previous state and an action as parameters, and return the next state. + +**[⬆ Back to Top](#table-of-contents)** + +155. ### What are the downsides of Redux compared to Flux? + + Instead of saying downsides we can say that there are few compromises of using Redux over Flux. Those are as follows: + + 1. **You will need to learn to avoid mutations:** Flux is un-opinionated about mutating data, but Redux doesn't like mutations and many packages complementary to Redux assume you never mutate the state. You can enforce this with dev-only packages like `redux-immutable-state-invariant`, Immutable.js, or instructing your team to write non-mutating code. + 2. **You're going to have to carefully pick your packages:** While Flux explicitly doesn't try to solve problems such as undo/redo, persistence, or forms, Redux has extension points such as middleware and store enhancers, and it has spawned a rich ecosystem. + 3. **There is no nice Flow integration yet:** Flux currently lets you do very impressive static type checks which Redux doesn't support yet. + +**[⬆ Back to Top](#table-of-contents)** + +156. ### What is the difference between `mapStateToProps()` and `mapDispatchToProps()`? + + `mapStateToProps()` is a utility which helps your component get updated state (which is updated by some other components): + + ```javascript + const mapStateToProps = (state) => { + return { + todos: getVisibleTodos(state.todos, state.visibilityFilter), + }; + }; + ``` + + `mapDispatchToProps()` is a utility which will help your component to fire an action event (dispatching action which may cause change of application state): + + ```javascript + const mapDispatchToProps = (dispatch) => { + return { + onTodoClick: (id) => { + dispatch(toggleTodo(id)); + }, + }; + }; + ``` + + It is recommended to always use the “object shorthand” form for the `mapDispatchToProps`. + + Redux wraps it in another function that looks like (…args) => dispatch(onTodoClick(…args)), and pass that wrapper function as a prop to your component. + + ```javascript + const mapDispatchToProps = { + onTodoClick, + }; + ``` + +**[⬆ Back to Top](#table-of-contents)** + +157. ### Can I dispatch an action in reducer? + + Dispatching an action within a reducer is an **anti-pattern**. Your reducer should be _without side effects_, simply digesting the action payload and returning a new state object. Adding listeners and dispatching actions within the reducer can lead to chained actions and other side effects. + +**[⬆ Back to Top](#table-of-contents)** + +158. ### How to access Redux store outside a component? + + You just need to export the store from the module where it created with `createStore()`. Also, it shouldn't pollute the global window object. + + ```javascript + store = createStore(myReducer); + + export default store; + ``` + +**[⬆ Back to Top](#table-of-contents)** + +159. ### What are the drawbacks of MVW pattern? + + 1. DOM manipulation is very expensive which causes applications to behave slow and inefficient. + 2. Due to circular dependencies, a complicated model was created around models and views. + 3. Lot of data changes happens for collaborative applications(like Google Docs). + 4. No way to do undo (travel back in time) easily without adding so much extra code. + +**[⬆ Back to Top](#table-of-contents)** + +160. ### Are there any similarities between Redux and RxJS? + + These libraries are very different for very different purposes, but there are some vague similarities. + + Redux is a tool for managing state throughout the application. It is usually used as an architecture for UIs. Think of it as an alternative to (half of) Angular. RxJS is a reactive programming library. It is usually used as a tool to accomplish asynchronous tasks in JavaScript. Think of it as an alternative to Promises. Redux uses the Reactive paradigm because the Store is reactive. The Store observes actions from a distance, and changes itself. RxJS also uses the Reactive paradigm, but instead of being an architecture, it gives you basic building blocks, Observables, to accomplish this pattern. + +**[⬆ Back to Top](#table-of-contents)** + +161. ### How to dispatch an action on load? + + You can dispatch an action in `componentDidMount()` method and in `render()` method you can verify the data. + + ```javascript + class App extends Component { + componentDidMount() { + this.props.fetchData(); + } + + render() { + return this.props.isLoaded ? ( +
{"Loaded"}
+ ) : ( +
{"Not Loaded"}
+ ); + } + } + + const mapStateToProps = (state) => ({ + isLoaded: state.isLoaded, + }); + + const mapDispatchToProps = { fetchData }; + + export default connect(mapStateToProps, mapDispatchToProps)(App); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +162. ### How to use `connect()` from React Redux? + + You need to follow two steps to use your store in your container: + + 1. **Use `mapStateToProps()`:** It maps the state variables from your store to the props that you specify. + 2. **Connect the above props to your container:** The object returned by the `mapStateToProps` function is connected to the container. You can import `connect()` from `react-redux`. + + ```jsx harmony + import React from "react"; + import { connect } from "react-redux"; + + class App extends React.Component { + render() { + return
{this.props.containerData}
; + } + } + + function mapStateToProps(state) { + return { containerData: state.data }; + } + + export default connect(mapStateToProps)(App); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +163. ### How to reset state in Redux? + + You need to write a _root reducer_ in your application which delegate handling the action to the reducer generated by `combineReducers()`. + + For example, let us take `rootReducer()` to return the initial state after `USER_LOGOUT` action. As we know, reducers are supposed to return the initial state when they are called with `undefined` as the first argument, no matter the action. + + ```javascript + const appReducer = combineReducers({ + /* your app's top-level reducers */ + }); + + const rootReducer = (state, action) => { + if (action.type === "USER_LOGOUT") { + state = undefined; + } + + return appReducer(state, action); + }; + ``` + + In case of using `redux-persist`, you may also need to clean your storage. `redux-persist` keeps a copy of your state in a storage engine. First, you need to import the appropriate storage engine and then, to parse the state before setting it to undefined and clean each storage state key. + + ```javascript + const appReducer = combineReducers({ + /* your app's top-level reducers */ + }); + + const rootReducer = (state, action) => { + if (action.type === "USER_LOGOUT") { + Object.keys(state).forEach((key) => { + storage.removeItem(`persist:${key}`); + }); + + state = undefined; + } + + return appReducer(state, action); + }; + ``` + +**[⬆ Back to Top](#table-of-contents)** + +164. ### Whats the purpose of `at` symbol in the Redux connect decorator? + + The **@** symbol is in fact a JavaScript expression used to signify decorators. _Decorators_ make it possible to annotate and modify classes and properties at design time. + + Let's take an example setting up Redux without and with a decorator. + + - **Without decorator:** + + ```javascript + import React from "react"; + import * as actionCreators from "./actionCreators"; + import { bindActionCreators } from "redux"; + import { connect } from "react-redux"; + + function mapStateToProps(state) { + return { todos: state.todos }; + } + + function mapDispatchToProps(dispatch) { + return { actions: bindActionCreators(actionCreators, dispatch) }; + } + + class MyApp extends React.Component { + // ...define your main app here + } + + export default connect(mapStateToProps, mapDispatchToProps)(MyApp); + ``` + + - **With decorator:** + + ```javascript + import React from "react"; + import * as actionCreators from "./actionCreators"; + import { bindActionCreators } from "redux"; + import { connect } from "react-redux"; + + function mapStateToProps(state) { + return { todos: state.todos }; + } + + function mapDispatchToProps(dispatch) { + return { actions: bindActionCreators(actionCreators, dispatch) }; + } + + @connect(mapStateToProps, mapDispatchToProps) + export default class MyApp extends React.Component { + // ...define your main app here + } + ``` + + The above examples are almost similar except the usage of decorator. The decorator syntax isn't built into any JavaScript runtimes yet, and is still experimental and subject to change. You can use babel for the decorators support. + +**[⬆ Back to Top](#table-of-contents)** + +165. ### What is the difference between React context and React Redux? + + You can use **Context** in your application directly and is going to be great for passing down data to deeply nested components which what it was designed for. + + Whereas **Redux** is much more powerful and provides a large number of features that the Context API doesn't provide. Also, React Redux uses context internally but it doesn't expose this fact in the public API. + +**[⬆ Back to Top](#table-of-contents)** + +166. ### Why are Redux state functions called reducers? + + Reducers always return the accumulation of the state (based on all previous and current actions). Therefore, they act as a reducer of state. Each time a Redux reducer is called, the state and action are passed as parameters. This state is then reduced (or accumulated) based on the action, and then the next state is returned. You could _reduce_ a collection of actions and an initial state (of the store) on which to perform these actions to get the resulting final state. + +**[⬆ Back to Top](#table-of-contents)** + +167. ### How to make AJAX request in Redux? + + You can use `redux-thunk` middleware which allows you to define async actions. + + Let's take an example of fetching specific account as an AJAX call using _fetch API_: + + ```javascript + export function fetchAccount(id) { + return (dispatch) => { + dispatch(setLoadingAccountState()); // Show a loading spinner + fetch(`/account/${id}`, (response) => { + dispatch(doneFetchingAccount()); // Hide loading spinner + if (response.status === 200) { + dispatch(setAccount(response.json)); // Use a normal function to set the received state + } else { + dispatch(someError); + } + }); + }; + } + + function setAccount(data) { + return { type: "SET_Account", data: data }; + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +168. ### Should I keep all component's state in Redux store? + + Keep your data in the Redux store, and the UI related state internally in the component. + +**[⬆ Back to Top](#table-of-contents)** + +169. ### What is the proper way to access Redux store? + + The best way to access your store in a component is to use the `connect()` function, that creates a new component that wraps around your existing one. This pattern is called _Higher-Order Components_, and is generally the preferred way of extending a component's functionality in React. This allows you to map state and action creators to your component, and have them passed in automatically as your store updates. + + Let's take an example of `` component using connect: + + ```javascript + import { connect } from "react-redux"; + import { setVisibilityFilter } from "../actions"; + import Link from "../components/Link"; + + const mapStateToProps = (state, ownProps) => ({ + active: ownProps.filter === state.visibilityFilter, + }); + + const mapDispatchToProps = (dispatch, ownProps) => ({ + onClick: () => dispatch(setVisibilityFilter(ownProps.filter)), + }); + + const FilterLink = connect(mapStateToProps, mapDispatchToProps)(Link); + + export default FilterLink; + ``` + + Due to it having quite a few performance optimizations and generally being less likely to cause bugs, the Redux developers almost always recommend using `connect()` over accessing the store directly (using context API). + + ```javascript + class MyComponent { + someMethod() { + doSomethingWith(this.context.store); + } + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +170. ### What is the difference between component and container in React Redux? + + **Component** is a class or function component that describes the presentational part of your application. + + **Container** is an informal term for a component that is connected to a Redux store. Containers _subscribe_ to Redux state updates and _dispatch_ actions, and they usually don't render DOM elements; they delegate rendering to presentational child components. + +**[⬆ Back to Top](#table-of-contents)** + +171. ### What is the purpose of the constants in Redux? + + Constants allows you to easily find all usages of that specific functionality across the project when you use an IDE. It also prevents you from introducing silly bugs caused by typos – in which case, you will get a `ReferenceError` immediately. + + Normally we will save them in a single file (`constants.js` or `actionTypes.js`). + + ```javascript + export const ADD_TODO = "ADD_TODO"; + export const DELETE_TODO = "DELETE_TODO"; + export const EDIT_TODO = "EDIT_TODO"; + export const COMPLETE_TODO = "COMPLETE_TODO"; + export const COMPLETE_ALL = "COMPLETE_ALL"; + export const CLEAR_COMPLETED = "CLEAR_COMPLETED"; + ``` + + In Redux, you use them in two places: + + 1. **During action creation:** + + Let's take `actions.js`: + + ```javascript + import { ADD_TODO } from "./actionTypes"; + + export function addTodo(text) { + return { type: ADD_TODO, text }; + } + ``` + + 2. **In reducers:** + + Let's create `reducer.js`: + + ```javascript + import { ADD_TODO } from "./actionTypes"; + + export default (state = [], action) => { + switch (action.type) { + case ADD_TODO: + return [ + ...state, + { + text: action.text, + completed: false, + }, + ]; + default: + return state; + } + }; + ``` + +**[⬆ Back to Top](#table-of-contents)** + +172. ### What are the different ways to write `mapDispatchToProps()`? + + There are a few ways of binding _action creators_ to `dispatch()` in `mapDispatchToProps()`. + + Below are the possible options: + + ```javascript + const mapDispatchToProps = (dispatch) => ({ + action: () => dispatch(action()), + }); + ``` + + ```javascript + const mapDispatchToProps = (dispatch) => ({ + action: bindActionCreators(action, dispatch), + }); + ``` + + ```javascript + const mapDispatchToProps = { action }; + ``` + + The third option is just a shorthand for the first one. + +**[⬆ Back to Top](#table-of-contents)** + +173. ### What is the use of the `ownProps` parameter in `mapStateToProps()` and `mapDispatchToProps()`? + + If the `ownProps` parameter is specified, React Redux will pass the props that were passed to the component into your _connect_ functions. So, if you use a connected component: + + ```jsx harmony + import ConnectedComponent from "./containers/ConnectedComponent"; + + ; + ``` + + The `ownProps` inside your `mapStateToProps()` and `mapDispatchToProps()` functions will be an object: + + ```javascript + { + user: "john"; + } + ``` + + You can use this object to decide what to return from those functions. + +**[⬆ Back to Top](#table-of-contents)** + +174. ### How to structure Redux top level directories? + + Most of the applications has several top-level directories as below: + + 1. **Components**: Used for _dumb_ components unaware of Redux. + 2. **Containers**: Used for _smart_ components connected to Redux. + 3. **Actions**: Used for all action creators, where file names correspond to part of the app. + 4. **Reducers**: Used for all reducers, where files name correspond to state key. + 5. **Store**: Used for store initialization. + + This structure works well for small and medium size apps. + +**[⬆ Back to Top](#table-of-contents)** + +175. ### What is redux-saga? + + `redux-saga` is a library that aims to make side effects (asynchronous things like data fetching and impure things like accessing the browser cache) in React/Redux applications easier and better. + + It is available in NPM: + + ```console + $ npm install --save redux-saga + ``` + +**[⬆ Back to Top](#table-of-contents)** + +176. ### What is the mental model of redux-saga? + + _Saga_ is like a separate thread in your application, that's solely responsible for side effects. `redux-saga` is a redux _middleware_, which means this thread can be started, paused and cancelled from the main application with normal Redux actions, it has access to the full Redux application state and it can dispatch Redux actions as well. + +**[⬆ Back to Top](#table-of-contents)** + +177. ### What are the differences between `call()` and `put()` in redux-saga? + + Both `call()` and `put()` are effect creator functions. `call()` function is used to create effect description, which instructs middleware to call the promise. `put()` function creates an effect, which instructs middleware to dispatch an action to the store. + + Let's take example of how these effects work for fetching particular user data. + + ```javascript + function* fetchUserSaga(action) { + // `call` function accepts rest arguments, which will be passed to `api.fetchUser` function. + // Instructing middleware to call promise, it resolved value will be assigned to `userData` variable + const userData = yield call(api.fetchUser, action.userId); + + // Instructing middleware to dispatch corresponding action. + yield put({ + type: "FETCH_USER_SUCCESS", + userData, + }); + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +178. ### What is Redux Thunk? + + _Redux Thunk_ middleware allows you to write action creators that return a function instead of an action. The thunk can be used to delay the dispatch of an action, or to dispatch only if a certain condition is met. The inner function receives the store methods `dispatch()` and `getState()` as parameters. + +**[⬆ Back to Top](#table-of-contents)** + +179. ### What are the differences between `redux-saga` and `redux-thunk`? + + Both _Redux Thunk_ and _Redux Saga_ take care of dealing with side effects. In most of the scenarios, Thunk uses _Promises_ to deal with them, whereas Saga uses _Generators_. Thunk is simple to use and Promises are familiar to many developers, Sagas/Generators are more powerful but you will need to learn them. But both middleware can coexist, so you can start with Thunks and introduce Sagas when/if you need them. + +**[⬆ Back to Top](#table-of-contents)** + +180. ### What is Redux DevTools? + + _Redux DevTools_ is a live-editing time travel environment for Redux with hot reloading, action replay, and customizable UI. If you don't want to bother with installing Redux DevTools and integrating it into your project, consider using Redux DevTools Extension for Chrome and Firefox. + +**[⬆ Back to Top](#table-of-contents)** + +181. ### What are the features of Redux DevTools? + + Some of the main features of Redux DevTools are below, + + 1. Lets you inspect every state and action payload. + 2. Lets you go back in time by _cancelling_ actions. + 3. If you change the reducer code, each _staged_ action will be re-evaluated. + 4. If the reducers throw, you will see during which action this happened, and what the error was. + 5. With `persistState()` store enhancer, you can persist debug sessions across page reloads. + +**[⬆ Back to Top](#table-of-contents)** + +182. ### What are Redux selectors and why to use them? + + _Selectors_ are functions that take Redux state as an argument and return some data to pass to the component. + + For example, to get user details from the state: + + ```javascript + const getUserData = (state) => state.user.data; + ``` + + These selectors have two main benefits, + + 1. The selector can compute derived data, allowing Redux to store the minimal possible state + 2. The selector is not recomputed unless one of its arguments changes + +**[⬆ Back to Top](#table-of-contents)** + +183. ### What is Redux Form? + + _Redux Form_ works with React and Redux to enable a form in React to use Redux to store all of its state. Redux Form can be used with raw HTML5 inputs, but it also works very well with common UI frameworks like Material UI, React Widgets and React Bootstrap. + +**[⬆ Back to Top](#table-of-contents)** + +184. ### What are the main features of Redux Form? + + Some of the main features of Redux Form are: + + 1. Field values persistence via Redux store. + 2. Validation (sync/async) and submission. + 3. Formatting, parsing and normalization of field values. + +**[⬆ Back to Top](#table-of-contents)** + +185. ### How to add multiple middlewares to Redux? + + You can use `applyMiddleware()`. + + For example, you can add `redux-thunk` and `logger` passing them as arguments to `applyMiddleware()`: + + ```javascript + import { createStore, applyMiddleware } from "redux"; + const createStoreWithMiddleware = applyMiddleware( + ReduxThunk, + logger + )(createStore); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +186. ### How to set initial state in Redux? + + You need to pass initial state as second argument to createStore: + + ```javascript + const rootReducer = combineReducers({ + todos: todos, + visibilityFilter: visibilityFilter, + }); + + const initialState = { + todos: [{ id: 123, name: "example", completed: false }], + }; + + const store = createStore(rootReducer, initialState); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +187. ### How Relay is different from Redux? + + Relay is similar to Redux in that they both use a single store. The main difference is that relay only manages state originated from the server, and all access to the state is used via _GraphQL_ queries (for reading data) and mutations (for changing data). Relay caches the data for you and optimizes data fetching for you, by fetching only changed data and nothing more. + +188. ### What is an action in Redux? + + _Actions_ are plain JavaScript objects or payloads of information that send data from your application to your store. They are the only source of information for the store. Actions must have a type property that indicates the type of action being performed. + + For example, let's take an action which represents adding a new todo item: + + ``` + { + type: ADD_TODO, + text: 'Add todo item' + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +## React Native + +**[⬆ Back to Top](#table-of-contents)** + +188. ### What is the difference between React Native and React? + + **React** is a JavaScript library, supporting both front end web and being run on the server, for building user interfaces and web applications. + + **React Native** is a mobile framework that compiles to native app components, allowing you to build native mobile applications (iOS, Android, and Windows) in JavaScript that allows you to use React to build your components, and implements React under the hood. + +**[⬆ Back to Top](#table-of-contents)** + +189. ### How to test React Native apps? + + React Native can be tested only in mobile simulators like iOS and Android. You can run the app in your mobile using expo app (https://expo.io) Where it syncs using QR code, your mobile and computer should be in same wireless network. + +**[⬆ Back to Top](#table-of-contents)** + +190. ### How to do logging in React Native? + + You can use `console.log`, `console.warn`, etc. As of React Native v0.29 you can simply run the following to see logs in the console: + + ``` + $ react-native log-ios + $ react-native log-android + ``` + +**[⬆ Back to Top](#table-of-contents)** + +191. ### How to debug your React Native? + + Follow the below steps to debug React Native app: + + 1. Run your application in the iOS simulator. + 2. Press `Command + D` and a webpage should open up at `http://localhost:8081/debugger-ui`. + 3. Enable _Pause On Caught Exceptions_ for a better debugging experience. + 4. Press `Command + Option + I` to open the Chrome Developer tools, or open it via `View` -> `Developer` -> `Developer Tools`. + 5. You should now be able to debug as you normally would. + +## React supported libraries & Integration + +**[⬆ Back to Top](#table-of-contents)** + +192. ### What is reselect and how it works? + + _Reselect_ is a **selector library** (for Redux) which uses _memoization_ concept. It was originally written to compute derived data from Redux-like applications state, but it can't be tied to any architecture or library. + + Reselect keeps a copy of the last inputs/outputs of the last call, and recomputes the result only if one of the inputs changes. If the the same inputs are provided twice in a row, Reselect returns the cached output. It's memoization and cache are fully customizable. + +**[⬆ Back to Top](#table-of-contents)** + +193. ### What is Flow? + + _Flow_ is a _static type checker_ designed to find type errors in JavaScript. Flow types can express much more fine-grained distinctions than traditional type systems. For example, Flow helps you catch errors involving `null`, unlike most type systems. + +**[⬆ Back to Top](#table-of-contents)** + +194. ### What is the difference between Flow and PropTypes? + + Flow is a _static analysis tool_ (static checker) which uses a superset of the language, allowing you to add type annotations to all of your code and catch an entire class of bugs at compile time. + + PropTypes is a _basic type checker_ (runtime checker) which has been patched onto React. It can't check anything other than the types of the props being passed to a given component. If you want more flexible typechecking for your entire project Flow/TypeScript are appropriate choices. + +**[⬆ Back to Top](#table-of-contents)** + +195. ### How to use Font Awesome icons in React? + + The below steps followed to include Font Awesome in React: + + 1. Install `font-awesome`: + + ```console + $ npm install --save font-awesome + ``` + + 2. Import `font-awesome` in your `index.js` file: + + ```javascript + import "font-awesome/css/font-awesome.min.css"; + ``` + + 3. Add Font Awesome classes in `className`: + + ```javascript + render() { + return
+ } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +196. ### What is React Dev Tools? + + _React Developer Tools_ let you inspect the component hierarchy, including component props and state. It exists both as a browser extension (for Chrome and Firefox), and as a standalone app (works with other environments including Safari, IE, and React Native). + + The official extensions available for different browsers or environments. + + 1. **Chrome extension** + 2. **Firefox extension** + 3. **Standalone app** (Safari, React Native, etc) + +**[⬆ Back to Top](#table-of-contents)** + +197. ### Why is DevTools not loading in Chrome for local files? + + If you opened a local HTML file in your browser (`file://...`) then you must first open _Chrome Extensions_ and check `Allow access to file URLs`. + +**[⬆ Back to Top](#table-of-contents)** + +198. ### How to use Polymer in React? + + You need to follow below steps to use Polymer in React, + + 1. Create a Polymer element: + + ```jsx harmony + ; + Polymer({ + is: "calender-element", + ready: function () { + this.textContent = "I am a calender"; + }, + }); + ``` + + 2. Create the Polymer component HTML tag by importing it in a HTML document, e.g. import it in the `index.html` of your React application: + + ```html + + ``` + + 3. Use that element in the JSX file: + + ```javascript + import React from "react"; + + class MyComponent extends React.Component { + render() { + return ; + } + } + + export default MyComponent; + ``` + +**[⬆ Back to Top](#table-of-contents)** + +199. ### What are the advantages of React over Vue.js? + + React has the following advantages over Vue.js: + + 1. Gives more flexibility in large apps developing. + 2. Easier to test. + 3. Suitable for mobile apps creating. + 4. More information and solutions available. + +**Note:** The above list of advantages are purely opinionated and it vary based on the professional experience. But they are helpful as base parameters. + +**[⬆ Back to Top](#table-of-contents)** + +200. ### What is the difference between React and Angular? + + Let's see the difference between React and Angular in a table format. + + | React | Angular | + | ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | + | React is a library and has only the View layer | Angular is a framework and has complete MVC functionality | + | React handles rendering on the server side | AngularJS renders only on the client side but Angular 2 and above renders on the server side | + | React uses JSX that looks like HTML in JS which can be confusing | Angular follows the template approach for HTML, which makes code shorter and easy to understand | + | React Native, which is a React type to build mobile applications are faster and more stable | Ionic, Angular's mobile native app is relatively less stable and slower | + | In React, data flows only in one way and hence debugging is easy | In Angular, data flows both way i.e it has two-way data binding between children and parent and hence debugging is often difficult | + +**Note:** The above list of differences are purely opinionated and it vary based on the professional experience. But they are helpful as base parameters. + +**[⬆ Back to Top](#table-of-contents)** + +201. ### Why React tab is not showing up in DevTools? + + When the page loads, _React DevTools_ sets a global named `__REACT_DEVTOOLS_GLOBAL_HOOK__`, then React communicates with that hook during initialization. If the website is not using React or if React fails to communicate with DevTools then it won't show up the tab. + +**[⬆ Back to Top](#table-of-contents)** + +202. ### What are Styled Components? + + `styled-components` is a JavaScript library for styling React applications. It removes the mapping between styles and components, and lets you write actual CSS augmented with JavaScript. + +**[⬆ Back to Top](#table-of-contents)** + +203. ### Give an example of Styled Components? + + Lets create `` and `<Wrapper>` components with specific styles for each. + + ```javascript + import React from "react"; + import styled from "styled-components"; + + // Create a <Title> component that renders an <h1> which is centered, red and sized at 1.5em + const Title = styled.h1` + font-size: 1.5em; + text-align: center; + color: palevioletred; + `; + + // Create a <Wrapper> component that renders a <section> with some padding and a papayawhip background + const Wrapper = styled.section` + padding: 4em; + background: papayawhip; + `; + ``` + + These two variables, `Title` and `Wrapper`, are now components that you can render just like any other react component. + + ```jsx harmony + <Wrapper> + <Title>{"Lets start first styled component!"} + + ``` + +**[⬆ Back to Top](#table-of-contents)** + +204. ### What is Relay? + + Relay is a JavaScript framework for providing a data layer and client-server communication to web applications using the React view layer. + +**[⬆ Back to Top](#table-of-contents)** + +205. ### How to use TypeScript in `create-react-app` application? + + Starting from react-scripts@2.1.0 or higher, there is a built-in support for typescript. i.e, `create-react-app` now supports typescript natively. You can just pass `--typescript` option as below + + ```bash + npx create-react-app my-app --typescript + + # or + + yarn create react-app my-app --typescript + ``` + + But for lower versions of react scripts, just supply `--scripts-version` option as `react-scripts-ts` while you create a new project. `react-scripts-ts` is a set of adjustments to take the standard `create-react-app` project pipeline and bring TypeScript into the mix. + + Now the project layout should look like the following: + + ``` + my-app/ + ├─ .gitignore + ├─ images.d.ts + ├─ node_modules/ + ├─ public/ + ├─ src/ + │ └─ ... + ├─ package.json + ├─ tsconfig.json + ├─ tsconfig.prod.json + ├─ tsconfig.test.json + └─ tslint.json + ``` + +## Miscellaneous + +**[⬆ Back to Top](#table-of-contents)** + +206. ### What are the main features of Reselect library? + + Let's see the main features of Reselect library, + + 1. Selectors can compute derived data, allowing Redux to store the minimal possible state. + 2. Selectors are efficient. A selector is not recomputed unless one of its arguments changes. + 3. Selectors are composable. They can be used as input to other selectors. + +207. #### Give an example of Reselect usage? + + Let's take calculations and different amounts of a shipment order with the simplified usage of Reselect: + + ```javascript + import { createSelector } from "reselect"; + + const shopItemsSelector = (state) => state.shop.items; + const taxPercentSelector = (state) => state.shop.taxPercent; + + const subtotalSelector = createSelector(shopItemsSelector, (items) => + items.reduce((acc, item) => acc + item.value, 0) + ); + + const taxSelector = createSelector( + subtotalSelector, + taxPercentSelector, + (subtotal, taxPercent) => subtotal * (taxPercent / 100) + ); + + export const totalSelector = createSelector( + subtotalSelector, + taxSelector, + (subtotal, tax) => ({ total: subtotal + tax }) + ); + + let exampleState = { + shop: { + taxPercent: 8, + items: [ + { name: "apple", value: 1.2 }, + { name: "orange", value: 0.95 }, + ], + }, + }; + + console.log(subtotalSelector(exampleState)); // 2.15 + console.log(taxSelector(exampleState)); // 0.172 + console.log(totalSelector(exampleState)); // { total: 2.322 } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +209. ### Does the statics object work with ES6 classes in React? + + No, `statics` only works with `React.createClass()`: + + ```javascript + someComponent = React.createClass({ + statics: { + someMethod: function () { + // .. + }, + }, + }); + ``` + + But you can write statics inside ES6+ classes as below, + + ```javascript + class Component extends React.Component { + static propTypes = { + // ... + }; + + static someMethod() { + // ... + } + } + ``` + + or writing them outside class as below, + + ```javascript + class Component extends React.Component { + .... + } + + Component.propTypes = {...} + Component.someMethod = function(){....} + ``` + +**[⬆ Back to Top](#table-of-contents)** + +210. ### Can Redux only be used with React? + + Redux can be used as a data store for any UI layer. The most common usage is with React and React Native, but there are bindings available for Angular, Angular 2, Vue, Mithril, and more. Redux simply provides a subscription mechanism which can be used by any other code. + +**[⬆ Back to Top](#table-of-contents)** + +211. ### Do you need to have a particular build tool to use Redux? + + Redux is originally written in ES6 and transpiled for production into ES5 with Webpack and Babel. You should be able to use it regardless of your JavaScript build process. Redux also offers a UMD build that can be used directly without any build process at all. + +**[⬆ Back to Top](#table-of-contents)** + +212. ### How Redux Form `initialValues` get updated from state? + + You need to add `enableReinitialize : true` setting. + + ```javascript + const InitializeFromStateForm = reduxForm({ + form: "initializeFromState", + enableReinitialize: true, + })(UserEdit); + ``` + + If your `initialValues` prop gets updated, your form will update too. + +**[⬆ Back to Top](#table-of-contents)** + +213. ### How React PropTypes allow different types for one prop? + + You can use `oneOfType()` method of `PropTypes`. + + For example, the height property can be defined with either `string` or `number` type as below: + + ```javascript + Component.propTypes = { + size: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + }; + ``` + +**[⬆ Back to Top](#table-of-contents)** + +214. ### Can I import an SVG file as react component? + + You can import SVG directly as component instead of loading it as a file. This feature is available with `react-scripts@2.0.0` and higher. + + ```jsx harmony + import { ReactComponent as Logo } from "./logo.svg"; + + const App = () => ( +
+ {/* Logo is an actual react component */} + +
+ ); + ``` + + **Note**: Don't forget about the curly braces in the import. + +**[⬆ Back to Top](#table-of-contents)** + +215. ### Why are inline ref callbacks or functions not recommended? + + If the ref callback is defined as an inline function, it will get called twice during updates, first with null and then again with the DOM element. This is because a new instance of the function is created with each render, so React needs to clear the old ref and set up the new one. + + ```jsx + class UserForm extends Component { + handleSubmit = () => { + console.log("Input Value is: ", this.input.value); + }; + + render() { + return ( +
+ (this.input = input)} /> // + Access DOM input in handle submit + +
+ ); + } + } + ``` + + But our expectation is for the ref callback to get called once, when the component mounts. One quick fix is to use the ES7 class property syntax to define the function + + ```jsx + class UserForm extends Component { + handleSubmit = () => { + console.log("Input Value is: ", this.input.value); + }; + + setSearchInput = (input) => { + this.input = input; + }; + + render() { + return ( +
+ // Access DOM input + in handle submit + +
+ ); + } + } + ``` + + **Note:** In React v16.3, + **[⬆ Back to Top](#table-of-contents)** + +216. ### What is render hijacking in react? + + The concept of render hijacking is the ability to control what a component will output from another component. It means that you decorate your component by wrapping it into a Higher-Order component. By wrapping, you can inject additional props or make other changes, which can cause changing logic of rendering. It does not actually enable hijacking, but by using HOC you make your component behave differently. + +**[⬆ Back to Top](#table-of-contents)** + +217. ### What are HOC factory implementations? + + There are two main ways of implementing HOCs in React. + + 1. Props Proxy (PP) and + 2. Inheritance Inversion (II). + + But they follow different approaches for manipulating the _WrappedComponent_. + + **Props Proxy** + + In this approach, the render method of the HOC returns a React Element of the type of the WrappedComponent. We also pass through the props that the HOC receives, hence the name **Props Proxy**. + + ```jsx + function ppHOC(WrappedComponent) { + return class PP extends React.Component { + render() { + return ; + } + }; + } + ``` + + **Inheritance Inversion** + + In this approach, the returned HOC class (Enhancer) extends the WrappedComponent. It is called Inheritance Inversion because instead of the WrappedComponent extending some Enhancer class, it is passively extended by the Enhancer. In this way the relationship between them seems **inverse**. + + ```jsx + function iiHOC(WrappedComponent) { + return class Enhancer extends WrappedComponent { + render() { + return super.render(); + } + }; + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +218. ### How to pass numbers to React component? + + You should be passing the numbers via curly braces({}) where as strings in quotes + + ```jsx + React.render( + , + document.getElementById("container") + ); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +219. ### Do I need to keep all my state into Redux? Should I ever use react internal state? + + It is up to the developer's decision, i.e., it is developer's job to determine what kinds of state make up your application, and where each piece of state should live. Some users prefer to keep every single piece of data in Redux, to maintain a fully serializable and controlled version of their application at all times. Others prefer to keep non-critical or UI state, such as “is this dropdown currently open”, inside a component's internal state. + + Below are the thumb rules to determine what kind of data should be put into Redux + + 1. Do other parts of the application care about this data? + 2. Do you need to be able to create further derived data based on this original data? + 3. Is the same data being used to drive multiple components? + 4. Is there value to you in being able to restore this state to a given point in time (ie, time travel debugging)? + 5. Do you want to cache the data (i.e, use what's in state if it's already there instead of re-requesting it)? + +**[⬆ Back to Top](#table-of-contents)** + +220. ### What is the purpose of registerServiceWorker in React? + + React creates a service worker for you without any configuration by default. The service worker is a web API that helps you cache your assets and other files so that when the user is offline or on a slow network, he/she can still see results on the screen, as such, it helps you build a better user experience, that's what you should know about service worker for now. It's all about adding offline capabilities to your site. + + ```jsx + import React from "react"; + import ReactDOM from "react-dom"; + import App from "./App"; + import registerServiceWorker from "./registerServiceWorker"; + + ReactDOM.render(, document.getElementById("root")); + registerServiceWorker(); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +221. ### What is React memo function? + + Class components can be restricted from re-rendering when their input props are the same using **PureComponent or shouldComponentUpdate**. Now you can do the same with function components by wrapping them in **React.memo**. + + ```jsx + const MyComponent = React.memo(function MyComponent(props) { + /* only rerenders if props change */ + }); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +222. ### What is React lazy function? + + The `React.lazy` function lets you render a dynamic import as a regular component. It will automatically load the bundle containing the `OtherComponent` when the component gets rendered. This must return a Promise which resolves to a module with a default export containing a React component. + + ```jsx + const OtherComponent = React.lazy(() => import("./OtherComponent")); + + function MyComponent() { + return ( +
+ +
+ ); + } + ``` + + **Note:** + `React.lazy` and `Suspense` is not yet available for server-side rendering. If you want to do code-splitting in a server rendered app, we still recommend React Loadable. + +**[⬆ Back to Top](#table-of-contents)** + +223. ### How to prevent unnecessary updates using setState? + + You can compare the current value of the state with an existing state value and decide whether to rerender the page or not. If the values are the same then you need to return **null** to stop re-rendering otherwise return the latest state value. + + For example, the user profile information is conditionally rendered as follows, + + ```jsx + getUserProfile = (user) => { + const latestAddress = user.address; + this.setState((state) => { + if (state.address === latestAddress) { + return null; + } else { + return { title: latestAddress }; + } + }); + }; + ``` + +**[⬆ Back to Top](#table-of-contents)** + +224. ### How do you render Array, Strings and Numbers in React 16 Version? + + **Arrays**: Unlike older releases, you don't need to make sure **render** method return a single element in React16. You are able to return multiple sibling elements without a wrapping element by returning an array. + + For example, let us take the below list of developers, + + ```jsx + const ReactJSDevs = () => { + return [ +
  • John
  • , +
  • Jackie
  • , +
  • Jordan
  • , + ]; + }; + ``` + + You can also merge this array of items in another array component. + + ```jsx + const JSDevs = () => { + return ( +
      +
    • Brad
    • +
    • Brodge
    • + +
    • Brandon
    • +
    + ); + }; + ``` + + **Strings and Numbers:** You can also return string and number type from the render method. + + ```jsx + render() { + return 'Welcome to ReactJS questions'; + } + // Number + render() { + return 2018; + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +225. ### How to use class field declarations syntax in React classes? + + React Class Components can be made much more concise using the class field declarations. You can initialize the local state without using the constructor and declare class methods by using arrow functions without the extra need to bind them. + + Let's take a counter example to demonstrate class field declarations for state without using constructor and methods without binding, + + ```jsx + class Counter extends Component { + state = { value: 0 }; + + handleIncrement = () => { + this.setState((prevState) => ({ + value: prevState.value + 1, + })); + }; + + handleDecrement = () => { + this.setState((prevState) => ({ + value: prevState.value - 1, + })); + }; + + render() { + return ( +
    + {this.state.value} + + + +
    + ); + } + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +226. ### What are hooks? + + Hooks is a special function (introduced as a new feature in React 16.8) that lets you use state and other React features without writing a class. + + Let's see an example of useState hook: + + ```jsx + import { useState } from "react"; + + function Example() { + // Declare a new state variable, which we'll call "count" + const [count, setCount] = useState(0); + + return ( +
    +

    You clicked {count} times

    + +
    + ); + } + ``` + + **Note:** Hooks can be used inside an existing function component. + +**[⬆ Back to Top](#table-of-contents)** + +227. ### What rules need to be followed for hooks? + + You need to follow two rules in order to use hooks, + + 1. Call Hooks only at the top level of your react functions. i.e, You shouldn’t call Hooks inside loops, conditions, or nested functions. This will ensure that Hooks are called in the same order each time a component renders and it preserves the state of Hooks between multiple useState and useEffect calls. + 2. Call Hooks from React Functions only. i.e, You shouldn’t call Hooks from regular JavaScript functions. + +**[⬆ Back to Top](#table-of-contents)** + +228. ### How to ensure hooks followed the rules in your project? + React team released an ESLint plugin called **eslint-plugin-react-hooks** that enforces these two rules. You can add this plugin to your project using the below command, + ```javascript + npm install eslint-plugin-react-hooks@next + ``` + And apply the below config in your ESLint config file, + ```javascript + // Your ESLint configuration + { + "plugins": [ + // ... + "react-hooks" + ], + "rules": { + // ... + "react-hooks/rules-of-hooks": "error" + } + } + ``` + **Note:** This plugin is intended to use in Create React App by default. + +**[⬆ Back to Top](#table-of-contents)** + +229. ### What are the differences between Flux and Redux? + + Below are the major differences between Flux and Redux + + | Flux | Redux | + | ---------------------------------------------- | ------------------------------------------ | + | State is mutable | State is immutable | + | The Store contains both state and change logic | The Store and change logic are separate | + | There are multiple stores exist | There is only one store exist | + | All the stores are disconnected and flat | Single store with hierarchical reducers | + | It has a singleton dispatcher | There is no concept of dispatcher | + | React components subscribe to the store | Container components uses connect function | + +**[⬆ Back to Top](#table-of-contents)** + +230. ### What are the benefits of React Router V4? + + Below are the main benefits of React Router V4 module, + + 1. In React Router v4(version 4), the API is completely about components. A router can be visualized as a single component(``) which wraps specific child router components(``). + 2. You don't need to manually set history. The router module will take care history by wrapping routes with `` component. + 3. The application size is reduced by adding only the specific router module(Web, core, or native) + +**[⬆ Back to Top](#table-of-contents)** + +231. ### Can you describe about componentDidCatch lifecycle method signature? + + The **componentDidCatch** lifecycle method is invoked after an error has been thrown by a descendant component. The method receives two parameters, + + 1. error: - The error object which was thrown + 2. info: - An object with a componentStack key contains the information about which component threw the error. + + The method structure would be as follows + + ```javascript + componentDidCatch(error, info); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +232. ### In which scenarios error boundaries do not catch errors? + + Below are the cases in which error boundaries doesn't work, + + 1. Inside Event handlers + 2. Asynchronous code using **setTimeout or requestAnimationFrame** callbacks + 3. During Server side rendering + 4. When errors thrown in the error boundary code itself + +**[⬆ Back to Top](#table-of-contents)** + +233. ### Why do you not need error boundaries for event handlers? + + Error boundaries do not catch errors inside event handlers. + + React doesn’t need error boundaries to recover from errors in event handlers. Unlike the render method and lifecycle methods, the event handlers don’t happen during rendering. So if they throw, React still knows what to display on the screen. + + If you need to catch an error inside an event handler, use the regular JavaScript try / catch statement: + + ```javascript + class MyComponent extends React.Component { + constructor(props) { + super(props); + this.state = { error: null }; + this.handleClick = this.handleClick.bind(this); + } + + handleClick() { + try { + // Do something that could throw + } catch (error) { + this.setState({ error }); + } + } + + render() { + if (this.state.error) { + return

    Caught an error.

    ; + } + return ; + } + } + ``` + + Note that the above example is demonstrating regular JavaScript behavior and doesn’t use error boundaries. + +**[⬆ Back to Top](#table-of-contents)** + +234. ### What is the difference between try catch block and error boundaries? + + Try catch block works with imperative code whereas error boundaries are meant for declarative code to render on the screen. + + For example, the try catch block used for below imperative code + + ```javascript + try { + showButton(); + } catch (error) { + // ... + } + ``` + + Whereas error boundaries wrap declarative code as below, + + ```javascript + + + + ``` + + So if an error occurs in a **componentDidUpdate** method caused by a **setState** somewhere deep in the tree, it will still correctly propagate to the closest error boundary. + +**[⬆ Back to Top](#table-of-contents)** + +235. ### What is the behavior of uncaught errors in react 16? + In React 16, errors that were not caught by any error boundary will result in unmounting of the whole React component tree. The reason behind this decision is that it is worse to leave corrupted UI in place than to completely remove it. For example, it is worse for a payments app to display a wrong amount than to render nothing. + +**[⬆ Back to Top](#table-of-contents)** + +236. ### What is the proper placement for error boundaries? + The granularity of error boundaries usage is up to the developer based on project needs. You can follow either of these approaches, + 1. You can wrap top-level route components to display a generic error message for the entire application. + 2. You can also wrap individual components in an error boundary to protect them from crashing the rest of the application. + +**[⬆ Back to Top](#table-of-contents)** + +237. ### What is the benefit of component stack trace from error boundary? + + Apart from error messages and javascript stack, React16 will display the component stack trace with file names and line numbers using error boundary concept. + + For example, BuggyCounter component displays the component stack trace as below, + + ![stacktrace](images/error_boundary.png) + +**[⬆ Back to Top](#table-of-contents)** + +238. ### What is the required method to be defined for a class component? + The `render()` method is the only required method in a class component. i.e, All methods other than render method are optional for a class component. + +**[⬆ Back to Top](#table-of-contents)** + +239. ### What are the possible return types of render method? + + Below are the list of following types used and return from render method, + + 1. **React elements:** Elements that instruct React to render a DOM node. It includes html elements such as `
    ` and user defined elements. + 2. **Arrays and fragments:** Return multiple elements to render as Arrays and Fragments to wrap multiple elements + 3. **Portals:** Render children into a different DOM subtree. + 4. **String and numbers:** Render both Strings and Numbers as text nodes in the DOM + 5. **Booleans or null:** Doesn't render anything but these types are used to conditionally render content. + +**[⬆ Back to Top](#table-of-contents)** + +240. ### What is the main purpose of constructor? + + The constructor is mainly used for two purposes, + + 1. To initialize local state by assigning object to this.state + 2. For binding event handler methods to the instance + For example, the below code covers both the above cases, + + ```javascript + constructor(props) { + super(props); + // Don't call this.setState() here! + this.state = { counter: 0 }; + this.handleClick = this.handleClick.bind(this); + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +241. ### Is it mandatory to define constructor for React component? + No, it is not mandatory. i.e, If you don’t initialize state and you don’t bind methods, you don’t need to implement a constructor for your React component. + +**[⬆ Back to Top](#table-of-contents)** + +242. ### What are default props? + + The defaultProps are defined as a property on the component class to set the default props for the class. This is used for undefined props, but not for null props. + + For example, let us create color default prop for the button component, + + ```javascript + class MyButton extends React.Component { + // ... + } + + MyButton.defaultProps = { + color: "red", + }; + ``` + + If `props.color` is not provided then it will set the default value to 'red'. i.e, Whenever you try to access the color prop it uses default value + + ```javascript + render() { + return ; // props.color will be set to red + } + ``` + + **Note:** If you provide null value then it remains null value. + +**[⬆ Back to Top](#table-of-contents)** + +243. ### Why should not call setState in componentWillUnmount? + You should not call `setState()` in `componentWillUnmount()` because once a component instance is unmounted, it will never be mounted again. + +**[⬆ Back to Top](#table-of-contents)** + +244. ### What is the purpose of getDerivedStateFromError? + + This lifecycle method is invoked after an error has been thrown by a descendant component. It receives the error that was thrown as a parameter and should return a value to update state. + + The signature of the lifecycle method is as follows, + + ```javascript + static getDerivedStateFromError(error) + ``` + + Let us take error boundary use case with the above lifecycle method for demonstration purpose, + + ```javascript + class ErrorBoundary extends React.Component { + constructor(props) { + super(props); + this.state = { hasError: false }; + } + + static getDerivedStateFromError(error) { + // Update state so the next render will show the fallback UI. + return { hasError: true }; + } + + render() { + if (this.state.hasError) { + // You can render any custom fallback UI + return

    Something went wrong.

    ; + } + + return this.props.children; + } + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +245. ### What is the methods order when component re-rendered? + + An update can be caused by changes to props or state. The below methods are called in the following order when a component is being re-rendered. + + 1. static getDerivedStateFromProps() + 2. shouldComponentUpdate() + 3. render() + 4. getSnapshotBeforeUpdate() + 5. componentDidUpdate() + +**[⬆ Back to Top](#table-of-contents)** + +246. ### What are the methods invoked during error handling? + + Below methods are called when there is an error during rendering, in a lifecycle method, or in the constructor of any child component. + + 1. static getDerivedStateFromError() + 2. componentDidCatch() + +**[⬆ Back to Top](#table-of-contents)** + +247. ### What is the purpose of displayName class property? + + The displayName string is used in debugging messages. Usually, you don’t need to set it explicitly because it’s inferred from the name of the function or class that defines the component. You might want to set it explicitly if you want to display a different name for debugging purposes or when you create a higher-order component. + + For example, To ease debugging, choose a display name that communicates that it’s the result of a withSubscription HOC. + + ```javascript + function withSubscription(WrappedComponent) { + class WithSubscription extends React.Component { + /* ... */ + } + WithSubscription.displayName = `WithSubscription(${getDisplayName( + WrappedComponent + )})`; + return WithSubscription; + } + function getDisplayName(WrappedComponent) { + return ( + WrappedComponent.displayName || WrappedComponent.name || "Component" + ); + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +248. ### What is the browser support for react applications? + React supports all popular browsers, including Internet Explorer 9 and above, although some polyfills are required for older browsers such as IE 9 and IE 10. If you use **es5-shim and es5-sham** polyfill then it even support old browsers that doesn't support ES5 methods. + +**[⬆ Back to Top](#table-of-contents)** + +249. ### What is the purpose of unmountComponentAtNode method? + + This method is available from react-dom package and it removes a mounted React component from the DOM and clean up its event handlers and state. If no component was mounted in the container, calling this function does nothing. Returns true if a component was unmounted and false if there was no component to unmount. + + The method signature would be as follows, + + ```javascript + ReactDOM.unmountComponentAtNode(container); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +250. ### What is code-splitting? + + Code-Splitting is a feature supported by bundlers like Webpack and Browserify which can create multiple bundles that can be dynamically loaded at runtime. The react project supports code splitting via dynamic import() feature. + + For example, in the below code snippets, it will make moduleA.js and all its unique dependencies as a separate chunk that only loads after the user clicks the 'Load' button. + **moduleA.js** + + ```javascript + const moduleA = "Hello"; + + export { moduleA }; + ``` + + **App.js** + + ```javascript + import React, { Component } from "react"; + + class App extends Component { + handleClick = () => { + import("./moduleA") + .then(({ moduleA }) => { + // Use moduleA + }) + .catch((err) => { + // Handle failure + }); + }; + + render() { + return ( +
    + +
    + ); + } + } + + export default App; + ``` + +**[⬆ Back to Top](#table-of-contents)** + +251. ### What is the benefit of strict mode? + + The will be helpful in the below cases + + 1. Identifying components with **unsafe lifecycle methods**. + 2. Warning about **legacy string ref** API usage. + 3. Detecting unexpected **side effects**. + 4. Detecting **legacy context** API. + 5. Warning about deprecated findDOMNode usage + +**[⬆ Back to Top](#table-of-contents)** + +252. ### What are Keyed Fragments? + + The Fragments declared with the explicit syntax may have keys. The general use case is mapping a collection to an array of fragments as below, + + ```javascript + function Glossary(props) { + return ( +
    + {props.items.map((item) => ( + // Without the `key`, React will fire a key warning + +
    {item.term}
    +
    {item.description}
    +
    + ))} +
    + ); + } + ``` + + **Note:** key is the only attribute that can be passed to Fragment. In the future, there might be a support for additional attributes, such as event handlers. + +**[⬆ Back to Top](#table-of-contents)** + +253. ### Does React support all HTML attributes? + + As of React 16, both standard or custom DOM attributes are fully supported. Since React components often take both custom and DOM-related props, React uses the camelCase convention just like the DOM APIs. + + Let us take few props with respect to standard HTML attributes, + + ```javascript +
    // Just like node.tabIndex DOM API +
    // Just like node.className DOM API + // Just like node.readOnly DOM API + ``` + + These props work similarly to the corresponding HTML attributes, with the exception of the special cases. It also support all SVG attributes. + +**[⬆ Back to Top](#table-of-contents)** + +254. ### What are the limitations with HOCs? + + Higher-order components come with a few caveats apart from its benefits. Below are the few listed in an order, + + 1. **Don’t use HOCs inside the render method:** + It is not recommended to apply a HOC to a component within the render method of a component. + + ```javascript + render() { + // A new version of EnhancedComponent is created on every render + // EnhancedComponent1 !== EnhancedComponent2 + const EnhancedComponent = enhance(MyComponent); + // That causes the entire subtree to unmount/remount each time! + return ; + } + ``` + + The above code impacts on performance by remounting a component that causes the state of that component and all of its children to be lost. Instead, apply HOCs outside the component definition so that the resulting component is created only once. + + 2. **Static methods must be copied over:** + When you apply a HOC to a component the new component does not have any of the static methods of the original component + + ```javascript + // Define a static method + WrappedComponent.staticMethod = function () { + /*...*/ + }; + // Now apply a HOC + const EnhancedComponent = enhance(WrappedComponent); + + // The enhanced component has no static method + typeof EnhancedComponent.staticMethod === "undefined"; // true + ``` + + You can overcome this by copying the methods onto the container before returning it, + + ```javascript + function enhance(WrappedComponent) { + class Enhance extends React.Component { + /*...*/ + } + // Must know exactly which method(s) to copy :( + Enhance.staticMethod = WrappedComponent.staticMethod; + return Enhance; + } + ``` + + 3. **Refs aren’t passed through:** + For HOCs you need to pass through all props to the wrapped component but this does not work for refs. This is because ref is not really a prop similar to key. In this case you need to use the React.forwardRef API + +**[⬆ Back to Top](#table-of-contents)** + +255. ### How to debug forwardRefs in DevTools? + + **React.forwardRef** accepts a render function as parameter and DevTools uses this function to determine what to display for the ref forwarding component. + + For example, If you don't name the render function or not using displayName property then it will appear as ”ForwardRef” in the DevTools, + + ```javascript + const WrappedComponent = React.forwardRef((props, ref) => { + return ; + }); + ``` + + But If you name the render function then it will appear as **”ForwardRef(myFunction)”** + + ```javascript + const WrappedComponent = React.forwardRef(function myFunction(props, ref) { + return ; + }); + ``` + + As an alternative, You can also set displayName property for forwardRef function, + + ```javascript + function logProps(Component) { + class LogProps extends React.Component { + // ... + } + + function forwardRef(props, ref) { + return ; + } + + // Give this component a more helpful display name in DevTools. + // e.g. "ForwardRef(logProps(MyComponent))" + const name = Component.displayName || Component.name; + forwardRef.displayName = `logProps(${name})`; + + return React.forwardRef(forwardRef); + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +256. ### When component props defaults to true? + + If you pass no value for a prop, it defaults to true. This behavior is available so that it matches the behavior of HTML. + + For example, below expressions are equivalent, + + ```javascript + + + + ``` + + **Note:** It is not recommended to use this approach because it can be confused with the ES6 object shorthand (example, `{name}` which is short for `{name: name}`) + +**[⬆ Back to Top](#table-of-contents)** + +257. ### What is NextJS and major features of it? + + Next.js is a popular and lightweight framework for static and server‑rendered applications built with React. It also provides styling and routing solutions. Below are the major features provided by NextJS, + + 1. Server-rendered by default + 2. Automatic code splitting for faster page loads + 3. Simple client-side routing (page based) + 4. Webpack-based dev environment which supports (HMR) + 5. Able to implement with Express or any other Node.js HTTP server + 6. Customizable with your own Babel and Webpack configurations + +**[⬆ Back to Top](#table-of-contents)** + +258. ### How do you pass an event handler to a component? + + You can pass event handlers and other functions as props to child components. It can be used in child component as below, + + ```html + + ``` + +**[⬆ Back to Top](#table-of-contents)** + +259. ### Is it good to use arrow functions in render methods? + + Yes, You can use. It is often the easiest way to pass parameters to callback functions. But you need to optimize the performance while using it. + + ```javascript + class Foo extends Component { + handleClick() { + console.log("Click happened"); + } + render() { + return ; + } + } + ``` + + **Note:** Using an arrow function in render method creates a new function each time the component renders, which may have performance implications + +**[⬆ Back to Top](#table-of-contents)** + +260. ### How to prevent a function from being called multiple times? + + If you use an event handler such as **onClick or onScroll** and want to prevent the callback from being fired too quickly, then you can limit the rate at which callback is executed. This can be achieved in the below possible ways, + + 1. **Throttling:** Changes based on a time based frequency. For example, it can be used using \_.throttle lodash function + 2. **Debouncing:** Publish changes after a period of inactivity. For example, it can be used using \_.debounce lodash function + 3. **RequestAnimationFrame throttling:** Changes based on requestAnimationFrame. For example, it can be used using raf-schd lodash function + +**[⬆ Back to Top](#table-of-contents)** + +261. ### How JSX prevents Injection Attacks? + + React DOM escapes any values embedded in JSX before rendering them. Thus it ensures that you can never inject anything that’s not explicitly written in your application. Everything is converted to a string before being rendered. + + For example, you can embed user input as below, + + ```javascript + const name = response.potentiallyMaliciousInput; + const element =

    {name}

    ; + ``` + + This way you can prevent XSS(Cross-site-scripting) attacks in the application. + +**[⬆ Back to Top](#table-of-contents)** + +262. ### How do you update rendered elements? + + You can update UI(represented by rendered element) by passing the newly created element to ReactDOM's render method. + + For example, lets take a ticking clock example, where it updates the time by calling render method multiple times, + + ```javascript + function tick() { + const element = ( +
    +

    Hello, world!

    +

    It is {new Date().toLocaleTimeString()}.

    +
    + ); + ReactDOM.render(element, document.getElementById("root")); + } + + setInterval(tick, 1000); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +263. ### How do you say that props are readonly? + + When you declare a component as a function or a class, it must never modify its own props. + + Let us take a below capital function, + + ```javascript + function capital(amount, interest) { + return amount + interest; + } + ``` + + The above function is called “pure” because it does not attempt to change their inputs, and always return the same result for the same inputs. Hence, React has a single rule saying "All React components must act like pure functions with respect to their props." + +**[⬆ Back to Top](#table-of-contents)** + +264. ### How do you say that state updates are merged? + + When you call setState() in the component, React merges the object you provide into the current state. + + For example, let us take a facebook user with posts and comments details as state variables, + + ```javascript + constructor(props) { + super(props); + this.state = { + posts: [], + comments: [] + }; + } + ``` + + Now you can update them independently with separate `setState()` calls as below, + + ```javascript + componentDidMount() { + fetchPosts().then(response => { + this.setState({ + posts: response.posts + }); + }); + + fetchComments().then(response => { + this.setState({ + comments: response.comments + }); + }); + } + ``` + + As mentioned in the above code snippets, `this.setState({comments})` updates only comments variable without modifying or replacing `posts` variable. + +**[⬆ Back to Top](#table-of-contents)** + +265. ### How do you pass arguments to an event handler? + + During iterations or loops, it is common to pass an extra parameter to an event handler. This can be achieved through arrow functions or bind method. + + Let us take an example of user details updated in a grid, + + ```javascript + + + ``` + + In the both approaches, the synthetic argument `e` is passed as a second argument. You need to pass it explicitly for arrow functions and it will be passed automatically for `bind` method. + +**[⬆ Back to Top](#table-of-contents)** + +266. ### How to prevent component from rendering? + + You can prevent component from rendering by returning null based on specific condition. This way it can conditionally render component. + + ```javascript + function Greeting(props) { + if (!props.loggedIn) { + return null; + } + + return
    welcome, {props.name}
    ; + } + ``` + + ```javascript + class User extends React.Component { + constructor(props) { + super(props); + this.state = {loggedIn: false, name: 'John'}; + } + + render() { + return ( +
    + //Prevent component render if it is not loggedIn + + +
    + ); + } + ``` + + In the above example, the `greeting` component skips its rendering section by applying condition and returning null value. + +**[⬆ Back to Top](#table-of-contents)** + +267. ### What are the conditions to safely use the index as a key? + + There are three conditions to make sure, it is safe use the index as a key. + + 1. The list and items are static– they are not computed and do not change + 2. The items in the list have no ids + 3. The list is never reordered or filtered. + +**[⬆ Back to Top](#table-of-contents)** + +268. ### Should keys be globally unique? + + The keys used within arrays should be unique among their siblings but they don’t need to be globally unique. i.e, You can use the same keys with two different arrays. + + For example, the below `Book` component uses two arrays with different arrays, + + ```javascript + function Book(props) { + const index = ( +
      + {props.pages.map((page) => ( +
    • {page.title}
    • + ))} +
    + ); + const content = props.pages.map((page) => ( +
    +

    {page.title}

    +

    {page.content}

    +

    {page.pageNumber}

    +
    + )); + return ( +
    + {index} +
    + {content} +
    + ); + } + ``` + +**[⬆ Back to Top](#table-of-contents)** + +269. ### What is the popular choice for form handling? + + `Formik` is a form library for react which provides solutions such as validation, keeping track of the visited fields, and handling form submission. + + In detail, You can categorize them as follows, + + 1. Getting values in and out of form state + 2. Validation and error messages + 3. Handling form submission + + It is used to create a scalable, performant, form helper with a minimal API to solve annoying stuff. + +**[⬆ Back to Top](#table-of-contents)** + +270. ### What are the advantages of formik over redux form library? + + Below are the main reasons to recommend formik over redux form library, + + 1. The form state is inherently short-term and local, so tracking it in Redux (or any kind of Flux library) is unnecessary. + 2. Redux-Form calls your entire top-level Redux reducer multiple times ON EVERY SINGLE KEYSTROKE. This way it increases input latency for large apps. + 3. Redux-Form is 22.5 kB minified gzipped whereas Formik is 12.7 kB + +**[⬆ Back to Top](#table-of-contents)** + +271. ### Why are you not required to use inheritance? + In React, it is recommended to use composition over inheritance to reuse code between components. Both Props and composition give you all the flexibility you need to customize a component’s look and behavior explicitly and safely. + Whereas, If you want to reuse non-UI functionality between components, it is suggested to extract it into a separate JavaScript module. Later components import it and use that function, object, or class, without extending it. + +**[⬆ Back to Top](#table-of-contents)** + +272. ### Can I use web components in react application? + + Yes, you can use web components in a react application. Even though many developers won't use this combination, it may require especially if you are using third-party UI components that are written using Web Components. + + For example, let us use `Vaadin` date picker web component as below, + + ```javascript + import React, { Component } from "react"; + import "./App.css"; + import "@vaadin/vaadin-date-picker"; + class App extends Component { + render() { + return ( +
    + +
    + ); + } + } + export default App; + ``` + +**[⬆ Back to Top](#table-of-contents)** + +273. ### What is dynamic import? + + You can achieve code-splitting in your app using dynamic import. + + Let's take an example of addition, + + 1. **Normal Import** + + ```javascript + import { add } from "./math"; + console.log(add(10, 20)); + ``` + + 2. **Dynamic Import** + + ```javascript + import("./math").then((math) => { + console.log(math.add(10, 20)); + }); + ``` + +**[⬆ Back to Top](#table-of-contents)** + +274. ### What are loadable components? + + If you want to do code-splitting in a server rendered app, it is recommend to use Loadable Components because React.lazy and Suspense is not yet available for server-side rendering. Loadable lets you render a dynamic import as a regular component. + + Lets take an example, + + ```javascript + import loadable from "@loadable/component"; + + const OtherComponent = loadable(() => import("./OtherComponent")); + + function MyComponent() { + return ( +
    + +
    + ); + } + ``` + + Now OtherComponent will be loaded in a separated bundle + +**[⬆ Back to Top](#table-of-contents)** + +275. ### What is suspense component? + + If the module containing the dynamic import is not yet loaded by the time parent component renders, you must show some fallback content while you’re waiting for it to load using a loading indicator. This can be done using **Suspense** component. + + For example, the below code uses suspense component, + + ```javascript + const OtherComponent = React.lazy(() => import("./OtherComponent")); + + function MyComponent() { + return ( +
    + Loading...
    }> + + +
    + ); + } + ``` + + As mentioned in the above code, Suspense is wrapped above the lazy component. + +**[⬆ Back to Top](#table-of-contents)** + +276. ### What is route based code splitting? + + One of the best place to do code splitting is with routes. The entire page is going to re-render at once so users are unlikely to interact with other elements in the page at the same time. Due to this, the user experience won't be disturbed. + + Let us take an example of route based website using libraries like React Router with React.lazy, + + ```javascript + import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; + import React, { Suspense, lazy } from "react"; + + const Home = lazy(() => import("./routes/Home")); + const About = lazy(() => import("./routes/About")); + + const App = () => ( + + Loading...
    }> + + + + + + + ); + ``` + + In the above code, the code splitting will happen at each route level. + +**[⬆ Back to Top](#table-of-contents)** + +277. ### Give an example on How to use context? + + **Context** is designed to share data that can be considered **global** for a tree of React components. + + For example, in the code below lets manually thread through a “theme” prop in order to style the Button component. + + ```javascript + //Lets create a context with a default theme value "luna" + const ThemeContext = React.createContext("luna"); + // Create App component where it uses provider to pass theme value in the tree + class App extends React.Component { + render() { + return ( + + + + ); + } + } + // A middle component where you don't need to pass theme prop anymore + function Toolbar(props) { + return ( +
    + +
    + ); + } + // Lets read theme value in the button component to use + class ThemedButton extends React.Component { + static contextType = ThemeContext; + render() { + return
    + + ); + } +} + +``` + +## Using Sates in Functional Components + +Initially, we could not use state in functional components because it was only supported in class components. over the years hooks were implemented in functional component. The hooks that enable us to use state in functional component is called useState +The useState( ) hook returns an array of the current state and a function ( setState) that we can use to update the value of the current state. The array is being destructured so we can can see the variables the array holds that is, the initial state and the updated state lets see an example + +``` +function App() { + const [country, setCountry] = useState("i'm a Nigerian"); + const change = () => { + setCountry("i am a Canadian"); + }; + return ( +
    +

    Hello, {country}

    + +
    + ); +} +``` + +

    Props in Class Component

    + Props are referred to as "properties". props are passed into react component just like arguments are passed into functions . Props are being specified as attribute just like your html. for example if the name attribute is "name " we assign a value to name. so basically, props are object that contains an attribute and its corresponding value. Data can be passed from parent component to the children component, but this data is immutable, which means that we cannot modify the props across another component. here is an example +``` +class Introduction extends React.Component { + render() { + return

    Hello, my name is {this.props.name}

    ; + } +} + +class App extends React.Component { +render() { +return ( + +
    + + +
    +); +} +} + +``` + +## Props in Functional Components + +Props in functional components are similar to that of the class components, the difference is the absence of the 'this' keyword. We also destructure in a similar way without the 'this' keyword. they are also immutable in the functional component +``` + +function Food(props) { +return

    I love {props.fav}

    ; +} + +function App() { +return ( + +
    + + +
    +); +} + +``` +> As you can see in the example above there wasn't a need for the 'this' keyword. + +``` + +function Food(props) { +const { fav } = props; +return

    I love {fav}

    ; +} + +function App() { +return ( + +
    + + +
    +); +} + +``` +summary: + +*The functional components doesn't require the render method +*Class component require the render() method that returns JSX. + +To use states in functional component we use the **useState** hook. +To use State in class components we use the constructor method and the setState function. + +Functional components use the useEffect hook instead of lifecycle method [useEffect](https://www.w3schools.com/react/react_useeffect.asp ) + Class components uses Lifecycle method **componentWillUnmount** etc. [ Lifecycle methods](https://www.w3schools.com/react/react_lifecycle.asp ) + + **[⬆ Back to Top](#table-of-contents)** + + + + + +## Disclaimer + +The questions provided in this repository are the summary of frequently asked questions across numerous companies. We cannot guarantee that these questions will actually be asked during your interview process, nor should you focus on memorizing all of them. The primary purpose is for you to get a sense of what some companies might ask — do not get discouraged if you don't know the answer to all of them ⁠— that is ok! + +Good luck with your interview 😊 + +--- +``` From 8f962f2e048921a009767cff9b71c6ae5107260d Mon Sep 17 00:00:00 2001 From: sudheerj Date: Mon, 12 Dec 2022 21:01:15 +0800 Subject: [PATCH 002/149] Update collab --- README.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/README.md b/README.md index e412a3a2..d06640d1 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,6 @@ --- -

    - - Codestudio Logo - -

    - Explore the Best Free Resource to learn React and kickstart your journey as a react developer here. Earn a free certification in just 40 days. -

    -

    - ---- -
    Learn to code and get hired with Zero To Mastery:
      From 4e591dcb994f74a7344a70e53832c72228c5063a Mon Sep 17 00:00:00 2001 From: sudheerj Date: Mon, 12 Dec 2022 21:23:00 +0800 Subject: [PATCH 003/149] Update format for class over function component --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d06640d1..08bfe543 100644 --- a/README.md +++ b/README.md @@ -501,8 +501,9 @@ You can download the PDF and Epub version of this repository from the latest run 6. ### When to use a Class Component over a Function Component? If the component needs _state or lifecycle methods_ then use class component otherwise use function component. + _However, from React 16.8 with the addition of Hooks, you could use state , lifecycle methods and other features that were only available in class component right in your function component._ - _So, it is always recommended to use Function components, unless you need a React functionality whose Function component equivalent is not present yet, like Error Boundaries _ + _So, it is always recommended to use Function components, unless you need a React functionality whose Function component equivalent is not present yet, like Error Boundaries._ **[⬆ Back to Top](#table-of-contents)** From 8b1d4631b29b1dd40ceda017706566ce90484161 Mon Sep 17 00:00:00 2001 From: sudheerj Date: Tue, 13 Dec 2022 00:33:34 +0800 Subject: [PATCH 004/149] Updated state question with function component --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 08bfe543..e9276968 100644 --- a/README.md +++ b/README.md @@ -519,6 +519,23 @@ You can download the PDF and Epub version of this repository from the latest run Let's create a user component with message state, + ```jsx harmony + import React, { useState } from 'react'; + + function User() { + const [message, setMessage] = useState("Welcome to React world"); + + return ( +
      +

      {this.message}

      +
      + ); + } + ``` + +
      See Class +

      + ```jsx harmony class User extends React.Component { constructor(props) { @@ -538,6 +555,8 @@ You can download the PDF and Epub version of this repository from the latest run } } ``` +

      +
      ![state](images/state.jpg) From 8d255cd45fc18d514041be2e64151405aa347644 Mon Sep 17 00:00:00 2001 From: sudheerj Date: Thu, 15 Dec 2022 08:41:41 +0800 Subject: [PATCH 005/149] Update collab --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index e9276968..4662ab20 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,17 @@ --- +

      + + Codestudio Logo + +

      + Explore the Best Free Resource to learn React and kickstart your journey as a react developer. Earn a free certification in just 40 days. +

      +

      + +--- +
      Learn to code and get hired with Zero To Mastery:
        From 50e25c8b9cee6c9cd8ab090e4064b3e8634f904b Mon Sep 17 00:00:00 2001 From: HarukiNguyen <98737510+HarukiNguyen@users.noreply.github.com> Date: Mon, 26 Dec 2022 11:32:00 +0700 Subject: [PATCH 006/149] Update major features of React --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4662ab20..86c187cc 100644 --- a/README.md +++ b/README.md @@ -389,6 +389,7 @@ You can download the PDF and Epub version of this repository from the latest run The major features of React are: + - Uses **JSX** syntax, a syntax extension of JS that allows developers to write HTML in their JS code. - It uses **VirtualDOM** instead of RealDOM considering that RealDOM manipulations are expensive. - Supports **server-side rendering**. - Follows **Unidirectional** data flow or data binding. From d12292ee83e67fd7acff527e671505fb7dd22ec6 Mon Sep 17 00:00:00 2001 From: Hoai Phong Date: Tue, 3 Jan 2023 23:07:01 +0700 Subject: [PATCH 007/149] Update codeblock --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4662ab20..cb9eb2ac 100644 --- a/README.md +++ b/README.md @@ -1467,17 +1467,17 @@ You can download the PDF and Epub version of this repository from the latest run _The Equivalent Functional Component_ - ```javascript - import React, {useState} from 'react'; + ```javascript + import React, {useState} from 'react'; - const App = (props) => { - const [count, setCount] = useState(0); + const App = (props) => { + const [count, setCount] = useState(0); - return ( - // JSX - ) - } - ``` + return ( + // JSX + ) + } + ``` **[⬆ Back to Top](#table-of-contents)** From 44435871ca523001ac2c0def3b758e61312b43cb Mon Sep 17 00:00:00 2001 From: Harshal Devmurari <92778686+Harshal2502@users.noreply.github.com> Date: Sat, 7 Jan 2023 21:45:51 +0530 Subject: [PATCH 008/149] Update the Navigation link --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c77b1f4d..41dc1f04 100644 --- a/README.md +++ b/README.md @@ -375,7 +375,7 @@ You can download the PDF and Epub version of this repository from the latest run | 330 | [What is prop drilling?](#what-is-prop-drilling) | | 331 | [What is state mutation and how to prevent it?](#what-is-state-mutation-and-how-to-prevent-it) | | 332 | [What is the difference between useState and useRef hook?](#what-is-the-difference-between-usestate-and-useref-hook) | -| 333 | [What are the Differences Between Functional and Class Component in React](#what-are-the-differences-between-functional-and-class-component-in-react) | +| 333 | [What are the differences between Functional and Class Components ](#what-are-the-differences-between-functional-and-class-components) | ## Core React @@ -6872,7 +6872,7 @@ const loadUser = async () => { **[⬆ Back to Top](#table-of-contents)** -333. ### What are the Differences Between Functional and Class Component +333. ### What are the differences between Functional and Class Components? ## Class Component syntax From fdc119f309708d8eabd48fa57f9bb84bb9d12ca4 Mon Sep 17 00:00:00 2001 From: Munehito BINOU Date: Sun, 8 Jan 2023 19:17:15 +0900 Subject: [PATCH 009/149] fix: question 7 typo --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 41dc1f04..3301b0f4 100644 --- a/README.md +++ b/README.md @@ -513,7 +513,7 @@ You can download the PDF and Epub version of this repository from the latest run 6. ### When to use a Class Component over a Function Component? If the component needs _state or lifecycle methods_ then use class component otherwise use function component. - + _However, from React 16.8 with the addition of Hooks, you could use state , lifecycle methods and other features that were only available in class component right in your function component._ _So, it is always recommended to use Function components, unless you need a React functionality whose Function component equivalent is not present yet, like Error Boundaries._ @@ -521,7 +521,7 @@ You can download the PDF and Epub version of this repository from the latest run 7. ### What are Pure Components? - _`React.PureComponent`_ is exactly the same as _`React.Component`_ except that it handles the `shouldComponentUpdate()` method for you. When props or state changes, _PureComponent_ will do a shallow comparison on both props and state. _Component_ on the other hand won't compare current props and state to next out of the box. Thus, the component will re-render by default whenever `shouldComponentUpdate` is called. In functional componenets we use `React.memo()` API. `React.memo()` is a higher-order component. It takes a React component as its first argument and returns a special type of React component that allows the renderer to render the component while memoizing the output. Therefore, if the component’s props are shallowly equal, the `React.memo()` component will bail out the updates. + _`React.PureComponent`_ is exactly the same as _`React.Component`_ except that it handles the `shouldComponentUpdate()` method for you. When props or state changes, _PureComponent_ will do a shallow comparison on both props and state. _Component_ on the other hand won't compare current props and state to next out of the box. Thus, the component will re-render by default whenever `shouldComponentUpdate` is called. In functional components we use `React.memo()` API. `React.memo()` is a higher-order component. It takes a React component as its first argument and returns a special type of React component that allows the renderer to render the component while memoizing the output. Therefore, if the component’s props are shallowly equal, the `React.memo()` component will bail out the updates. **[⬆ Back to Top](#table-of-contents)** @@ -6956,7 +6956,7 @@ function App() { ```

        Props in Class Component

        - Props are referred to as "properties". props are passed into react component just like arguments are passed into functions . Props are being specified as attribute just like your html. for example if the name attribute is "name " we assign a value to name. so basically, props are object that contains an attribute and its corresponding value. Data can be passed from parent component to the children component, but this data is immutable, which means that we cannot modify the props across another component. here is an example + Props are referred to as "properties". props are passed into react component just like arguments are passed into functions . Props are being specified as attribute just like your html. for example if the name attribute is "name " we assign a value to name. so basically, props are object that contains an attribute and its corresponding value. Data can be passed from parent component to the children component, but this data is immutable, which means that we cannot modify the props across another component. here is an example ``` class Introduction extends React.Component { render() { From 2d8221930177c564edeb532cc3cbe115210d9359 Mon Sep 17 00:00:00 2001 From: Munehito BINOU Date: Sun, 8 Jan 2023 19:18:01 +0900 Subject: [PATCH 010/149] fix: question 198 typo --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3301b0f4..cbd070ad 100644 --- a/README.md +++ b/README.md @@ -4319,9 +4319,9 @@ You can download the PDF and Epub version of this repository from the latest run href="../../bower_components/polymer/polymer.html" />; Polymer({ - is: "calender-element", + is: "calendar-element", ready: function () { - this.textContent = "I am a calender"; + this.textContent = "I am a calendar"; }, }); ``` @@ -4331,7 +4331,7 @@ You can download the PDF and Epub version of this repository from the latest run ```html ``` @@ -4342,7 +4342,7 @@ You can download the PDF and Epub version of this repository from the latest run class MyComponent extends React.Component { render() { - return ; + return ; } } From 636d4d3b0ac97b18791457584ec529bab0af7750 Mon Sep 17 00:00:00 2001 From: Munehito BINOU Date: Sun, 8 Jan 2023 19:26:56 +0900 Subject: [PATCH 011/149] fix: question 332 typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cbd070ad..1aa30ce3 100644 --- a/README.md +++ b/README.md @@ -6868,7 +6868,7 @@ const loadUser = async () => { 332. ### What is the difference between useState and useRef hook? 1. useState causes components to re-render after state updates whereas useRef doesn’t cause a component to re-render when the value or state changes. Essentially, useRef is like a “box” that can hold a mutable value in its (.current) property. - 2. useState allows us to update the state inside components. While useRef allows refrencing DOM elements. + 2. useState allows us to update the state inside components. While useRef allows referencing DOM elements. **[⬆ Back to Top](#table-of-contents)** From 97f8685621eae1749034ab65bbb5ad9103d52b78 Mon Sep 17 00:00:00 2001 From: Elyes Ben Abdelkader Date: Tue, 10 Jan 2023 21:27:07 +0100 Subject: [PATCH 012/149] Update question #104 answer --- README.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1aa30ce3..587d2693 100644 --- a/README.md +++ b/README.md @@ -2611,7 +2611,7 @@ You can download the PDF and Epub version of this repository from the latest run 104. ### Is it possible to use React without rendering HTML? - It is possible with latest version (>=16.2). Below are the possible options: + It is possible. Below are the possible options: ```jsx harmony render() { @@ -2619,18 +2619,34 @@ You can download the PDF and Epub version of this repository from the latest run } ``` + ```jsx harmony + render() { + return true + } + ``` + ```jsx harmony render() { return null } ``` + React version >=16.0.0: + ```jsx harmony render() { return [] } ``` + ```jsx harmony + render() { + return "" + } + ``` + + React version >=16.2.0: + ```jsx harmony render() { return @@ -2643,7 +2659,13 @@ You can download the PDF and Epub version of this repository from the latest run } ``` - Returning `undefined` won't work. + React version >=18.0.0: + + ```jsx harmony + render() { + return undefined + } + ``` **[⬆ Back to Top](#table-of-contents)** From 0649d4675ef9d16dc5b468a500dc9461b84e05e5 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Mon, 23 Jan 2023 13:43:08 +0800 Subject: [PATCH 013/149] Remove this in functional component --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 587d2693..48ab1b07 100644 --- a/README.md +++ b/README.md @@ -539,7 +539,7 @@ You can download the PDF and Epub version of this repository from the latest run return (
        -

        {this.message}

        +

        {message}

        ); } From acb8ac1a31cd9027626201ef0614ed6d0d9aba90 Mon Sep 17 00:00:00 2001 From: Sumit Date: Tue, 24 Jan 2023 22:34:55 +0530 Subject: [PATCH 014/149] new questions #333 and #334 added --- README.md | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 78 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 48ab1b07..bf440298 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,6 @@ Learn to code and get hired with -

        {message}

        -
      +
      +

      {message}

      +
      ); } ``` @@ -567,6 +568,7 @@ You can download the PDF and Epub version of this repository from the latest run } } ``` +

      @@ -6894,7 +6896,76 @@ const loadUser = async () => { **[⬆ Back to Top](#table-of-contents)** -333. ### What are the differences between Functional and Class Components? +333. ### What is a wrapper component? + + A wrapper in React is a component that wraps or surrounds another component or group of components. It can be used for a variety of purposes such as adding additional functionality, styling, or layout to the wrapped components. + + For example, consider a simple component that displays a message: + + ```javascript + const Message = ({ text }) => { + return

      {text}

      ; + }; + ``` + + We can create a wrapper component that will add a border to the message component: + + ```javascript + const MessageWrapper = (props) => { + return ( +
      + +
      + ); + }; + ``` + + Now we can use the MessageWrapper component instead of the Message component and the message will be displayed with a border: + + ```javascript + + ``` + + Wrapper component can also accept its own props and pass them down to the wrapped component, for example, we can create a wrapper component that will add a title to the message component: + + ```javascript + const MessageWrapperWithTitle = (props) => { + return ( +
      +

      {props.title}

      + +
      + ); + }; + ``` + + Now we can use the MessageWrapperWithTitle component and pass title props: + + ```javascript + + ``` + + This way, the wrapper component can add additional functionality, styling, or layout to the wrapped component while keeping the wrapped component simple and reusable. + +**[⬆ Back to Top](#table-of-contents)** + +334. ### What are the differences between useEffect and useLayoutEffect hooks? + + useEffect and useLayoutEffect are both React hooks that can be used to synchronize a component with an external system, such as a browser API or a third-party library. However, there are some key differences between the two: + + - Timing: useEffect runs after the browser has finished painting, while useLayoutEffect runs synchronously before the browser paints. This means that useLayoutEffect can be used to measure and update layout in a way that feels more synchronous to the user. + + - Browser Paint: useEffect allows browser to paint the changes before running the effect, hence it may cause some visual flicker. useLayoutEffect synchronously runs the effect before browser paints and hence it will avoid visual flicker. + + - Execution Order: The order in which multiple useEffect hooks are executed is determined by React and may not be predictable. However, the order in which multiple useLayoutEffect hooks are executed is determined by the order in which they were called. + + - Error handling: useEffect has a built-in mechanism for handling errors that occur during the execution of the effect, so that it does not crash the entire application. useLayoutEffect does not have this mechanism, and errors that occur during the execution of the effect will crash the entire application. + + In general, it's recommended to use useEffect as much as possible, because it is more performant and less prone to errors. useLayoutEffect should only be used when you need to measure or update layout, and you can't achieve the same result using useEffect. + +**[⬆ Back to Top](#table-of-contents)** + +335. ### What are the differences between Functional and Class Components? ## Class Component syntax From bf989f166d42bef011b84932a108ea66aa4cf148 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Mon, 30 Jan 2023 01:54:18 +0800 Subject: [PATCH 015/149] Remove github actions documentation --- .github/workflows/main.yaml | 34 ---------------------------------- README.md | 4 ---- 2 files changed, 38 deletions(-) delete mode 100644 .github/workflows/main.yaml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml deleted file mode 100644 index 8b41896e..00000000 --- a/.github/workflows/main.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: Documentation - -on: - push: - branches: [ master ] - -env: - FILE_NAME: react-interview-questions - -jobs: - convert_via_pandoc: - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - - name: Create output directory - run: | - mkdir output # create output dir - - - name: Create PDF - uses: docker://pandoc/latex:2.10 - with: - args: --pdf-engine=xelatex --output=output/${{env.FILE_NAME}}.pdf README.md - - - name: Create epub - uses: docker://pandoc/latex:2.10 - with: - args: --output=output/${{env.FILE_NAME}}.epub README.md - - - name: Upload - uses: actions/upload-artifact@master - with: - name: output - path: output \ No newline at end of file diff --git a/README.md b/README.md index bf440298..ff18d672 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,6 @@ Learn to code and get hired with
      { - (async () => { - const result = await axios( - "http://hn.algolia.com/api/v1/search?query=react" - ); - - setData(result.data); - })(); + React.useEffect(() => { + fetch("http://hn.algolia.com/api/v1/search?query=react") + .then(response => response.json()) + .then(data => setData(data)) }, []); return ( @@ -6439,7 +6434,9 @@ Learn to code and get hired with
    1. {todo.text}
    2. ); From cd0e5efb4bd8632011103c92fbb263786d068b7a Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Thu, 9 Feb 2023 23:59:57 +0800 Subject: [PATCH 018/149] Updated functional and class component differences --- README.md | 264 ++++++++++++++++++++++++------------------------------ 1 file changed, 115 insertions(+), 149 deletions(-) diff --git a/README.md b/README.md index 10e2fcb8..02e9cb6d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,15 @@ > Click :star:if you like the project. Pull Request are highly appreciated. Follow me [@SudheerJonna](https://twitter.com/SudheerJonna) for technical updates. --- +
      +Learn to code and get hired with Zero To Mastery: +
        +
      1. This React course is good if you’re struggling to learn React beyond the basics
      2. +
      3. This coding interview bootcamp is helpful if you’re serious about getting hired as a developer
      4. +
      +
      +---

      Codestudio Logo @@ -15,16 +23,6 @@ --- -

      -Learn to code and get hired with Zero To Mastery: -
        -
      1. This React course is good if you’re struggling to learn React beyond the basics
      2. -
      3. This coding interview bootcamp is helpful if you’re serious about getting hired as a developer
      4. -
      -
      - ---- - **Note:** This repository is specific to ReactJS. Please check [Javascript Interview questions](https://github.com/sudheerj/javascript-interview-questions) for core javascript questions. ### Table of Contents @@ -6962,168 +6960,136 @@ const loadUser = async () => { **[⬆ Back to Top](#table-of-contents)** 335. ### What are the differences between Functional and Class Components? + + There are two different ways to create components in ReactJS. The main differences are listed down as below, -## Class Component syntax - -``` -class Example extends Reacts.Component { -render(){ -return

      This is a class component

      } -} - -``` - -> I guess we all know that **Pascal Case** is the accepted way of naming a component in react`Example`. - -# Functional Component syntax - -Functional component has been improved over the years with some added features like Hooks -Here is a syntax for functional component - -``` -function App(){ - return
      -

      Hello, I'm a Nigerian

      -
      -} + ## 1. Syntax: -``` - -### States in Class Component - -states holds information or data about a component in react which may change over time. in class component we can update the state, when a user interacts with it or maybe a server response using the `setState()` method and the initial state is been assigned in the `Constructor( ) `method using the the ` this.state` object. different data type can be passed in the this.state object, which can be string, boolean, numbers, etc. - A simple example showing how we use the setState() and constructor() - -``` -class Example extends Component { - constructor() { - super(); - this.state = { - example: "This is a class component", - }; - } - changeText() { - this.setState({ - example: "implementing the setState() in class component", - }); - } - render() { - return ( - <> -

      {this.state.example}

      - - - ); - } -} - -``` - -## Using Sates in Functional Components - -Initially, we could not use state in functional components because it was only supported in class components. over the years hooks were implemented in functional component. The hooks that enable us to use state in functional component is called useState -The useState( ) hook returns an array of the current state and a function ( setState) that we can use to update the value of the current state. The array is being destructured so we can can see the variables the array holds that is, the initial state and the updated state lets see an example + The classs components uses ES6 classes to create the components. It uses `render` function to display the HTML content in the webpage. + + The syntax for class component looks like as below. + ``` + class App extends Reacts.Component { + render(){ + return

      This is a class component

      } + } -``` -function App() { - const [country, setCountry] = useState("i'm a Nigerian"); - const change = () => { - setCountry("i am a Canadian"); - }; - return ( -
      -

      Hello, {country}

      - -
      - ); -} -``` + ``` -

      Props in Class Component

      - Props are referred to as "properties". props are passed into react component just like arguments are passed into functions . Props are being specified as attribute just like your html. for example if the name attribute is "name " we assign a value to name. so basically, props are object that contains an attribute and its corresponding value. Data can be passed from parent component to the children component, but this data is immutable, which means that we cannot modify the props across another component. here is an example -``` -class Introduction extends React.Component { - render() { - return

      Hello, my name is {this.props.name}

      ; - } -} + **Note:** The **Pascal Case** is the recommended approach to provide naming to a component. -class App extends React.Component { -render() { -return ( + Functional component has been improved over the years with some added features like Hooks. Here is a syntax for functional component. -
      - - -
      -); -} -} - -``` - -## Props in Functional Components + ``` + function App(){ + return
      +

      Hello, I'm a function component

      +
      + } -Props in functional components are similar to that of the class components, the difference is the absence of the 'this' keyword. We also destructure in a similar way without the 'this' keyword. they are also immutable in the functional component -``` + ``` -function Food(props) { -return

      I love {props.fav}

      ; -} + ## 2. State: -function App() { -return ( + State contains information or data about a component which may change over time. + + In class component, you can update the state when a user interacts with it or server updates the data using the `setState()` method. The initial state is going to be assigned in the `Constructor( ) `method using the the ` this.state` object and it is possible to different data types in the `this.state` object such as string, boolean, numbers, etc. + A simple example showing how we use the setState() and constructor() -
      - - -
      -); -} + ``` + class App extends Component { + constructor() { + super(); + this.state = { + message: "This is a class component", + }; + } + updateMessage() { + this.setState({t + message: "Updating the class component", + }); + } + render() { + return ( + <> +

      {this.state.message}

      + + + ); + } + } -``` -> As you can see in the example above there wasn't a need for the 'this' keyword. + ``` -``` + You not use state in functional components because it was only supported in class components. But over the years hooks have been implemented in functional component which enable to use state in functional component too. + + The `useState()` hook can used to implement state in funcitonal component. It returns an array with two items: the first item is current state and the next one is a function (setState) that updates the value of the current state. + + Let's see an example to demonstrate the state in functional components, -function Food(props) { -const { fav } = props; -return

      I love {fav}

      ; -} + ``` + function App() { + const [message, setMessage] = useState("This is a functional component"); + const updateMessage = () => { + setCountry("Updating the functional component"); + }; + return ( +
      +

      {message}

      + +
      + ); + } + ``` -function App() { -return ( + ## 4. Props: + Props are referred to as "properties". The props are passed into react component just like arguments passed to a function. In otherwords, they are similar to HTML attributes. -
      - - -
      -); -} + The props are accessible in child class component using `this.props` as shown in below example, + ``` + class Child extends React.Component { + render() { + return

      This is a functional component and component name is {this.props.name}

      ; + } + } -``` -summary: + class Parent extends React.Component { + render() { + return ( +
      + + +
      + ); + } + } + ``` -*The functional components doesn't require the render method -*Class component require the render() method that returns JSX. + Props in functional components are similar to that of the class components but the difference is the absence of 'this' keyword. -To use states in functional component we use the **useState** hook. -To use State in class components we use the constructor method and the setState function. + ``` + function Child(props) { + return

      This is a child component and the component name is{props.name}

      ; + } -Functional components use the useEffect hook instead of lifecycle method [useEffect](https://www.w3schools.com/react/react_useeffect.asp ) - Class components uses Lifecycle method **componentWillUnmount** etc. [ Lifecycle methods](https://www.w3schools.com/react/react_lifecycle.asp ) + function Parent() { + return ( +
      + + +
      + ); + } + ``` **[⬆ Back to Top](#table-of-contents)** - - - ## Disclaimer The questions provided in this repository are the summary of frequently asked questions across numerous companies. We cannot guarantee that these questions will actually be asked during your interview process, nor should you focus on memorizing all of them. The primary purpose is for you to get a sense of what some companies might ask — do not get discouraged if you don't know the answer to all of them ⁠— that is ok! From bd15946f1691dca3e3671bd15bcb0309a1cb8d2d Mon Sep 17 00:00:00 2001 From: Dewey Nguyen Date: Thu, 16 Feb 2023 22:38:50 +0700 Subject: [PATCH 019/149] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 20ce11ad..ac671a36 100644 --- a/README.md +++ b/README.md @@ -6920,7 +6920,7 @@ const loadUser = async () => { Wrapper component can also accept its own props and pass them down to the wrapped component, for example, we can create a wrapper component that will add a title to the message component: ```javascript - const MessageWrapperWithTitle = (props) => { + const MessageWrapperWithTitle = ({title, ...props}) => { return (

      {props.title}

      From 1f5102ee34815bbf6678eb93502f5deaf3cad400 Mon Sep 17 00:00:00 2001 From: Dewey Nguyen Date: Thu, 16 Feb 2023 22:45:14 +0700 Subject: [PATCH 020/149] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac671a36..de5efe40 100644 --- a/README.md +++ b/README.md @@ -6923,7 +6923,7 @@ const loadUser = async () => { const MessageWrapperWithTitle = ({title, ...props}) => { return (
      -

      {props.title}

      +

      {title}

      ); From fe9560a17a08c646c975a68567c2404dd989b367 Mon Sep 17 00:00:00 2001 From: Chetan Nada Date: Sun, 5 Mar 2023 13:18:33 +0530 Subject: [PATCH 021/149] Added easy Explanation in Question 10 --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index de5efe40..1bf1a3e1 100644 --- a/README.md +++ b/README.md @@ -652,8 +652,10 @@ Learn to code and get hired with Date: Tue, 7 Mar 2023 22:11:38 +0800 Subject: [PATCH 022/149] Add question related to duplicated render --- README.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index de5efe40..fda63efb 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,15 @@ ---
      -Learn to code and get hired with Zero To Mastery: -
        -
      1. This React course is good if you’re struggling to learn React beyond the basics
      2. -
      3. This coding interview bootcamp is helpful if you’re serious about getting hired as a developer
      4. -
      +

      + + ZTM Logo + +

        +
      1. This React course is good if you’re struggling to learn React beyond the basics
      2. +
      3. This coding interview bootcamp is helpful if you’re serious about getting hired as a developer
      4. +
      +

      --- @@ -371,6 +375,8 @@ Learn to code and get hired with ` and `` components only. + React.StrictMode currently helps you with: + + 1. Identifying components with unsafe lifecycles + 2. Warning about legacy string ref API usage + 3. Warning about deprecated `findDOMNode` usage + 4. Detecting unexpected side effects + 5. Detecting legacy context API + **[⬆ Back to Top](#table-of-contents)** 84. ### What are React Mixins? @@ -7086,6 +7100,37 @@ const loadUser = async () => { **[⬆ Back to Top](#table-of-contents)** +336. ### Why does strict mode render twice in React? + + StrictMode renders components twice in development mode(not production) in order to detect any problems with your code and warn you about those problems. This is used to detect accidental side effects in the render phase. If you used `create-react-app` development tool then it automatically enables StrictMode by default. + + ```js + ReactDOM.render( + + {App} + , + document.getElementById('root') + ); + ``` + + If you want to disable this behavior then you can remove `strict` mode. + ```js + ReactDOM.render( + {App}, + document.getElementById('root') + ); + ``` + + To detect side effects the following functions are invoked twice: + + 1. Class component constructor, render, and shouldComponentUpdate methods + 2. Class component static getDerivedStateFromProps method + 3. Function component bodies + 4. State updater functions + 5. Functions passed to useState, useMemo, or useReducer (any Hook) + + **[⬆ Back to Top](#table-of-contents)** + ## Disclaimer From c079c4381ace1ebdf26030a3dd6477510d4a9d59 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Wed, 8 Mar 2023 20:02:32 +0800 Subject: [PATCH 023/149] Fixed format issue --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e0376fb7..ca53b518 100644 --- a/README.md +++ b/README.md @@ -375,14 +375,15 @@ | 333 | [What is a wrapper component ](#what-is-a-wrapper-component) | | 334 | [What are the differences between useEffect and useLayoutEffect hooks](#what-are-the-differences-between-useEffect-and-useLayoutEffect-hooks) | | 335 | [What are the differences between Functional and Class Components ](#what-are-the-differences-between-functional-and-class-components) | -| 336 | [Why does strict mode render twice in React?] -(#why-does-strict-mode-render-twice-in-react) | +| 336 | [Why does strict mode render twice in React?](#why-does-strict-mode-render-twice-in-react) | ## Core React 1. ### What is React? - React is an **open-source front-end JavaScript library** that is used for building user interfaces, especially for single-page applications. It is used for handling view layer for web and mobile apps. React was created by [Jordan Walke](https://github.com/jordwalke), a software engineer working for Facebook. React was first deployed on Facebook's News Feed in 2011 and on Instagram in 2012. + React(aka React.js or ReactJS) is an **open-source front-end JavaScript library** that is used for building composable user interfaces, especially for single-page applications. It is used for handling view layer for web and mobile apps based on components in a declarative approach. + + React was created by [Jordan Walke](https://github.com/jordwalke), a software engineer working for Facebook. React was first deployed on Facebook's News Feed in 2011 and on Instagram in 2012. **[⬆ Back to Top](#table-of-contents)** From 56baef4702e01f286ffa35af03fb9d4c6d3d5a45 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Fri, 10 Mar 2023 01:01:16 +0800 Subject: [PATCH 024/149] Update jsx questio --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ca53b518..d3207641 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ ZTM Logo
        -
      1. This React course is good if you’re struggling to learn React beyond the basics
      2. -
      3. This coding interview bootcamp is helpful if you’re serious about getting hired as a developer
      4. +
      5. I recommend this React course if you’re serious about learning React and want to go beyond the basics
      6. +
      7. Want to ace your coding interview and get hired at your dream company? Take this coding interview bootcamp

      @@ -401,7 +401,7 @@ 3. ### What is JSX? - _JSX_ is a XML-like syntax extension to ECMAScript (the acronym stands for _JavaScript XML_). Basically it just provides syntactic sugar for the `React.createElement()` function, giving us expressiveness of JavaScript along with HTML like template syntax. + _JSX_ stands for _JavaScript XML_ and it is a XML-like syntax extension to ECMAScript. Basically it just provides syntactic sugar for the `React.createElement()` function, giving us expressiveness of JavaScript along with HTML like template syntax. In the example below text inside `

      ` tag is returned as JavaScript function to the render function. From 7644e2dedba7d00e784e9ff0af1473ccb1b02629 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sat, 11 Mar 2023 01:08:33 +0800 Subject: [PATCH 025/149] Update JSX and state questions --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d3207641..4868f7eb 100644 --- a/README.md +++ b/README.md @@ -401,7 +401,7 @@ 3. ### What is JSX? - _JSX_ stands for _JavaScript XML_ and it is a XML-like syntax extension to ECMAScript. Basically it just provides syntactic sugar for the `React.createElement()` function, giving us expressiveness of JavaScript along with HTML like template syntax. + _JSX_ stands for _JavaScript XML_ and it is an XML-like syntax extension to ECMAScript. Basically it just provides syntactic sugar for the `React.createElement()` function, giving us expressiveness of JavaScript along with HTML like template syntax. In the example below text inside `

      ` tag is returned as JavaScript function to the render function. @@ -409,7 +409,7 @@ export default function App() { return (
      -

      {"Welcome to React world!"}

      +

      {"This is a JSX Code!"}

      ); } @@ -423,7 +423,7 @@ render() { return (
      -

      {"Welcome to React world!"}

      +

      {"This is a JSX Code!"}

      ); } @@ -529,7 +529,7 @@ 8. ### What is state in React? - _State_ of a component is an object that holds some information that may change over the lifetime of the component. We should always try to make our state as simple as possible and minimize the number of stateful components. + _State_ of a component is an object that holds some information that may change over the lifetime of the component. Whenever the state object changes, the component re-renders. We should always try to make our state as simple as possible and minimize the number of stateful components. Let's create a user component with message state, From cb5e043cfd437c5b61b92100b6c3fff5910f7b80 Mon Sep 17 00:00:00 2001 From: shahidullah muffakir Date: Mon, 13 Mar 2023 14:34:42 +0530 Subject: [PATCH 026/149] added functional component example to the question no.100, the class component example is unchanged --- README.md | 94 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 4868f7eb..5fc459b2 100644 --- a/README.md +++ b/README.md @@ -2548,43 +2548,75 @@ 100. ### How to re-render the view when the browser is resized? - You can listen to the `resize` event in `componentDidMount()` and then update the dimensions (`width` and `height`). You should remove the listener in `componentWillUnmount()` method. + You can use the `useState` hook to manage the width and height state variables, and the `useEffect` hook to add and remove the `resize` event listener. The `[]` dependency array passed to useEffect ensures that the effect only runs once (on mount) and not on every re-render. ```javascript - class WindowDimensions extends React.Component { - constructor(props) { - super(props); - this.updateDimensions = this.updateDimensions.bind(this); - } - - componentWillMount() { - this.updateDimensions(); - } - - componentDidMount() { - window.addEventListener("resize", this.updateDimensions); - } - - componentWillUnmount() { - window.removeEventListener("resize", this.updateDimensions); - } + import React, { useState, useEffect } from "react"; + function WindowDimensions() { + const [dimensions, setDimensions] = useState({ + width: window.innerWidth, + height: window.innerHeight, + }); - updateDimensions() { - this.setState({ - width: window.innerWidth, - height: window.innerHeight, - }); - } + useEffect(() => { + function handleResize() { + setDimensions({ + width: window.innerWidth, + height: window.innerHeight, + }); + } + window.addEventListener("resize", handleResize); + return () => window.removeEventListener("resize", handleResize); + }, []); - render() { - return ( - - {this.state.width} x {this.state.height} - - ); - } + return ( + + {dimensions.width} x {dimensions.height} + + ); } ``` +
      +

      Using Class Component

      + + You can listen to the `resize` event in `componentDidMount()` and then update the dimensions (`width` and `height`). You should remove the listener in `componentWillUnmount()` method. + + ```javascript + class WindowDimensions extends React.Component { + constructor(props) { + super(props); + this.updateDimensions = this.updateDimensions.bind(this); + } + + componentWillMount() { + this.updateDimensions(); + } + + componentDidMount() { + window.addEventListener("resize", this.updateDimensions); + } + + componentWillUnmount() { + window.removeEventListener("resize", this.updateDimensions); + } + + updateDimensions() { + this.setState({ + width: window.innerWidth, + height: window.innerHeight, + }); + } + + render() { + return ( + + {this.state.width} x {this.state.height} + + ); + } + } + ``` +
      **[⬆ Back to Top](#table-of-contents)** From bd75016efda381bc6a85df3e10dc13af014893a9 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Mon, 13 Mar 2023 17:27:26 +0800 Subject: [PATCH 027/149] Update state question --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4868f7eb..23a19bb6 100644 --- a/README.md +++ b/README.md @@ -529,9 +529,11 @@ 8. ### What is state in React? - _State_ of a component is an object that holds some information that may change over the lifetime of the component. Whenever the state object changes, the component re-renders. We should always try to make our state as simple as possible and minimize the number of stateful components. + _State_ of a component is an object that holds some information that may change over the lifetime of the component. The important point is whenever the state object changes, the component re-renders. It is always recommended to make our state as simple as possible and minimize the number of stateful components. - Let's create a user component with message state, + ![state](images/state.jpg) + + Let's take an example of **User** component with message state. Here, **useState** hook has been used to add state to the User component and it returns an array with current state and function to update it. ```jsx harmony import React, { useState } from "react"; @@ -573,8 +575,6 @@

      - ![state](images/state.jpg) - State is similar to props, but it is private and fully controlled by the component ,i.e., it is not accessible to any other component till the owner component decides to pass it. **[⬆ Back to Top](#table-of-contents)** From da8548ea37434ced4a34302e37f2d2243a0a2478 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sat, 18 Mar 2023 14:40:22 +0800 Subject: [PATCH 028/149] Update event questions --- README.md | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index a36d41d3..0ff92112 100644 --- a/README.md +++ b/README.md @@ -740,45 +740,45 @@ 14. ### How to bind methods or event handlers in JSX callbacks? - There are 3 possible ways to achieve this: + There are 3 possible ways to achieve this in class components: - 1. **Binding in Constructor:** In JavaScript classes, the methods are not bound by default. The same thing applies for React event handlers defined as class methods. Normally we bind them in constructor. + 1. **Binding in Constructor:** In JavaScript classes, the methods are not bound by default. The same rule applies for React event handlers defined as class methods. Normally we bind them in constructor. ```javascript - class Foo extends Component { + class User extends Component { constructor(props) { super(props); this.handleClick = this.handleClick.bind(this); } handleClick() { - console.log("Click happened"); + console.log("SingOut triggered"); } render() { - return ; + return ; } } ``` - 2. **Public class fields syntax:** If you don't like to use bind approach then _public class fields syntax_ can be used to correctly bind callbacks. + 2. **Public class fields syntax:** If you don't like to use bind approach then _public class fields syntax_ can be used to correctly bind callbacks. The Create React App eanables this syntax by default. ```jsx harmony handleClick = () => { - console.log("this is:", this); + console.log("SingOut triggered", this); }; ``` ```jsx harmony - + ``` - 3. **Arrow functions in callbacks:** You can use _arrow functions_ directly in the callbacks. + 3. **Arrow functions in callbacks:** It is possible to use _arrow functions_ directly in the callbacks. ```jsx harmony handleClick() { - console.log('Click happened'); + console.log('SingOut triggered'); } render() { - return ; + return ; } ``` @@ -813,7 +813,24 @@ 16. ### What are synthetic events in React? - `SyntheticEvent` is a cross-browser wrapper around the browser's native event. Its API is same as the browser's native event, including `stopPropagation()` and `preventDefault()`, except the events work identically across all browsers. + `SyntheticEvent` is a cross-browser wrapper around the browser's native event. Its API is same as the browser's native event, including `stopPropagation()` and `preventDefault()`, except the events work identically across all browsers. The native events can be accessed directly from synthetic events using `nativeEvent` attribute. + + Let's take an example of BookStore title search component with the ability to get all native event properties + + ```js + function BookStore() { + handleTitleChange(e) { + console.log('The new title is:', e.target.value); + // 'e' represents synthetic event + const nativeEvent = e.nativeEvent; + console.log(nativeEvent); + e.stopPropogation(); + e.preventDefault(); + } + + return + } + ``` **[⬆ Back to Top](#table-of-contents)** From b593449418caa4337c69fca206d7eec78b146bb9 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sun, 19 Mar 2023 18:09:58 +0800 Subject: [PATCH 029/149] Add react history question and update stateful component --- README.md | 62 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 0ff92112..7793d988 100644 --- a/README.md +++ b/README.md @@ -387,6 +387,15 @@ **[⬆ Back to Top](#table-of-contents)** +2. ### What is the history behind React evolution? + The history of ReactJS started in 2010 with the creation of XHP. XHP is a PHP extension which improved the syntax of the language such that XML document fragments become valid PHP expressions and the primary purpose was used to create custom and reusable HTML elements. The main principle of this extension was to make front-end code easier to understand and to help avoid cross-site scripting attacks. The project was successful to prevent the malicious content submitted by the scrubbing user. + + But there was a different problem with XHP in which dynamic web applications require many roundtrips to the server, and XHP did not solve this problem. Also, the whole UI was re-rendered for small change in the application. Later, the initial prototype of React is created with the name "FaxJS" by Jordan inspired from XHP. Finally after sometime React has been introduced as a new library into JavaScript world. + + **Note:** JSX comes from the idea of XHP + + **[⬆ Back to Top](#table-of-contents)** + 2. ### What are the major features of React? The major features of React are: @@ -1469,38 +1478,53 @@ 50. ### What are stateful components? - If the behaviour of a component is dependent on the _state_ of the component then it can be termed as stateful component. These _stateful components_ are always _class components_ and have a state that gets initialized in the `constructor`. + If the behaviour of a component is dependent on the _state_ of the component then it can be termed as stateful component. These _stateful components_ are either function components with hooks or _class components_. + Let's take an example of function stateful component which update the state based on click event, ```javascript + import React, {useState} from 'react'; + + const App = (props) => { + const [count, setCount] = useState(0); + handleIncrement() { + setCount(count+1); + } + + return ( + <> + + Counter: {count} + + ) + } + ``` + +
      See Class +

      + The equivalent class stateful component with a state that gets initialized in the `constructor`. + + ```jsx harmony class App extends Component { constructor(props) { super(props); this.state = { count: 0 }; } + handleIncrement() { + setState({count: this.state.count + 1}) + } + render() { - // ... + <> + + Count: {count} + } } ``` +

      +
      - **React 16.8 Update:** - - Hooks let you use state and other React features without writing classes. - - _The Equivalent Functional Component_ - - ```javascript - import React, {useState} from 'react'; - - const App = (props) => { - const [count, setCount] = useState(0); - - return ( - // JSX - ) - } - ``` **[⬆ Back to Top](#table-of-contents)** From e64b0c9b73e29e46e83cc7556dd122b0bbbf3964 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sat, 25 Mar 2023 19:49:47 +0800 Subject: [PATCH 030/149] Add coding questions --- README.md | 2 +- coding-exercise/README.md | 196 +++++++++++++++++++++++++++++++------- 2 files changed, 160 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 7793d988..38d43346 100644 --- a/README.md +++ b/README.md @@ -590,7 +590,7 @@ 9. ### What are props in React? - _Props_ are inputs to components. They are single values or objects containing a set of values that are passed to components on creation using a naming convention similar to HTML-tag attributes. They are data passed down from a parent component to a child component. + _Props_ are inputs to components. They are single values or objects containing a set of values that are passed to components on creation similar to HTML-tag attributes. They are data passed down from a parent component to a child component. The primary purpose of props in React is to provide following component functionality: diff --git a/coding-exercise/README.md b/coding-exercise/README.md index 9c40dcdc..7339d202 100644 --- a/coding-exercise/README.md +++ b/coding-exercise/README.md @@ -1,68 +1,190 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +### Coding Exercise + +#### 1. What is the output of below code + +```javascript +import { useState } from 'react'; -## Available Scripts +export default function Counter() { + const [counter, setCounter] = useState(5); + + return ( + <> + {counter} + + + ) +} +``` + +- 1: Alert with 5, 5 +- 2: Alert with 15, 25 +- 3: Alert with 5, 10 +- 4: Error: Cannot update the same state multiple times concurrently + +
      Answer +

      + +##### Answer: 3 +State values are fixed(i.e, default value 5) in each render and setting the state only changes it for the next render. React will wait untill all the code executed with in an event handler before your state updates follwed by re-rendering the UI. Also, all the 3 setter function calls are replacing the calculated value. Hence, irrespective of how many times you call `setCounter(counter + 5)` the final value is 10(5+5). + +This can be visuallized by substituting with state variable values in the particular render, +```javascript + +``` +

      +
      -In the project directory, you can run: +--- -### `yarn start` +**[⬆ Back to Top](#table-of-contents)** -Runs the app in the development mode.
      -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. +#### 2. What is the output of below code -The page will reload if you make edits.
      -You will also see any lint errors in the console. +```javascript +import { useState } from 'react'; -### `yarn test` +export default function Counter() { + const [counter, setCounter] = useState(5); + + return ( + <> + {counter} + + + ) +} +``` + +- 1: Alert with 5, 25 +- 2: Alert with 5, 10 +- 3: Alert with 15, 25 +- 4: Alert with 15, 10 + +
      Answer +

      + +##### Answer: 1 -Launches the test runner in the interactive watch mode.
      -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. +React queues all the updater functions(e.g, counter => counter + 5) which will be processed after all the code inside event handler has been executed. During the next re-render(state update through setState), React goes through the queue and increment the counter based on the previous value in each function call. So the final value of counter becomes 25(initial value 5 + 5 + 5 + 5 + 5) whereas the alert shows default value 5 because the counter value won't be updated by that time. -### `yarn build` +

      +
      -Builds the app for production to the `build` folder.
      -It correctly bundles React in production mode and optimizes the build for the best performance. +--- -The build is minified and the filenames include the hashes.
      -Your app is ready to be deployed! +**[⬆ Back to Top](#table-of-contents)** -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. +#### 3. What is the output of span after one click? -### `yarn eject` +```javascript +import { useRef } from 'react'; -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** +export default function Counter() { + let countRef = useRef(0); -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + function handleIncrement() { + countRef.current = countRef.current + 1; + } -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + return + <> + Count: {countRef.current} + + <> +} +``` -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. +- 1: Cannot read current property of undefined +- 2: Count: 1 +- 3: null +- 4: Count: 0 -## Learn More +
      Answer +

      -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). +##### Answer: 4 -To learn React, check out the [React documentation](https://reactjs.org/). +In React, every update has two phases. +1. **Render:** This is where React calls the components in order to output something on the screen +2. **Commit:** React applies changes to the DOM -### Code Splitting +Any updates to the ref will be reflected only in the commit phase. In other words, React sets **counterRef.current** during the commit phase. Hence, **countRef.current** always holds value `0` irrespective of how many times the Increment button clicked. +

      +
      -This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting +--- -### Analyzing the Bundle Size +**[⬆ Back to Top](#table-of-contents)** -This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size +#### 4. What is the outcome of below code after button click? -### Making a Progressive Web App +```javascript +import { useRef } from 'react'; -This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app +function MyCustomInput(props) { + return ; +} -### Advanced Configuration +export default function MyCustomForm() { + const inputRef = useRef(null); -This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration + function handleInputFocus() { + inputRef.current.focus(); + } -### Deployment + return ( + <> + + + + ); +} +``` -This section has moved here: https://facebook.github.io/create-react-app/docs/deployment +- 1: Input gets the focus +- 2: Warning: Function components cannot be given refs. +- 3: Cannot read current property of undefined +- 4: Warning: Missing ref on element -### `yarn build` fails to minify +
      Answer +

      + +##### Answer: 2 +By default, React does not allow a component access the DOM nodes of other components even for child components. If you still try to access the DOM nodes directly then you will receive below error: + +```javascript +Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()? +``` + +This issue can be fixed by wrapping the **** component with `forwardRef` function which accepts ref as the second argument which can be used on the **** element as **ref={ref}** + +

      +
      + +--- + +**[⬆ Back to Top](#table-of-contents)** -This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify From 98b66106b2d743e019d8d417dfc43db89c90650f Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sun, 26 Mar 2023 09:54:40 +0800 Subject: [PATCH 031/149] Update key attribute question --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 38d43346..0c2075cc 100644 --- a/README.md +++ b/README.md @@ -862,7 +862,7 @@ 18. ### What is "key" prop and what is the benefit of using it in arrays of elements? - A `key` is a special string attribute you **should** include when creating arrays of elements. _Key_ prop helps React identify which items have changed, are added, or are removed. + A `key` is a special attribute you **should** include when creating arrays of elements. _Key_ prop helps React identify which items have changed, are added, or are removed. Keys should be unique among its siblings. Most often we use ID from our data as _key_: @@ -883,6 +883,7 @@ 1. Using _indexes_ for _keys_ is **not recommended** if the order of items may change. This can negatively impact performance and may cause issues with component state. 2. If you extract list item as separate component then apply _keys_ on list component instead of `li` tag. 3. There will be a warning message in the console if the `key` prop is not present on list items. + 4. The key attribute accepts either string or number and internally convert it as string type. **[⬆ Back to Top](#table-of-contents)** From b75591b863b83efe0b328bc6c8e0e150bf902c59 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Mon, 27 Mar 2023 01:41:34 +0800 Subject: [PATCH 032/149] Improve react introduction questions --- README.md | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 0c2075cc..046cdb8a 100644 --- a/README.md +++ b/README.md @@ -388,9 +388,11 @@ **[⬆ Back to Top](#table-of-contents)** 2. ### What is the history behind React evolution? - The history of ReactJS started in 2010 with the creation of XHP. XHP is a PHP extension which improved the syntax of the language such that XML document fragments become valid PHP expressions and the primary purpose was used to create custom and reusable HTML elements. The main principle of this extension was to make front-end code easier to understand and to help avoid cross-site scripting attacks. The project was successful to prevent the malicious content submitted by the scrubbing user. + The history of ReactJS started in 2010 with the creation of **XHP**. XHP is a PHP extension which improved the syntax of the language such that XML document fragments become valid PHP expressions and the primary purpose was used to create custom and reusable HTML elements. + + The main principle of this extension was to make front-end code easier to understand and to help avoid cross-site scripting attacks. The project was successful to prevent the malicious content submitted by the scrubbing user. - But there was a different problem with XHP in which dynamic web applications require many roundtrips to the server, and XHP did not solve this problem. Also, the whole UI was re-rendered for small change in the application. Later, the initial prototype of React is created with the name "FaxJS" by Jordan inspired from XHP. Finally after sometime React has been introduced as a new library into JavaScript world. + But there was a different problem with XHP in which dynamic web applications require many roundtrips to the server, and XHP did not solve this problem. Also, the whole UI was re-rendered for small change in the application. Later, the initial prototype of React is created with the name **FaxJ** by Jordan inspired from XHP. Finally after sometime React has been introduced as a new library into JavaScript world. **Note:** JSX comes from the idea of XHP @@ -401,25 +403,36 @@ The major features of React are: - Uses **JSX** syntax, a syntax extension of JS that allows developers to write HTML in their JS code. - - It uses **VirtualDOM** instead of RealDOM considering that RealDOM manipulations are expensive. - - Supports **server-side rendering**. - - Follows **Unidirectional** data flow or data binding. + - It uses **Virtual DOM** instead of Real DOM considering that Real DOM manipulations are expensive. + - Supports **server-side rendering** which is useful for Search Engine Optimizations(SEO). + - Follows **Unidirectional or one-way** data flow or data binding. - Uses **reusable/composable** UI components to develop the view. **[⬆ Back to Top](#table-of-contents)** 3. ### What is JSX? - _JSX_ stands for _JavaScript XML_ and it is an XML-like syntax extension to ECMAScript. Basically it just provides syntactic sugar for the `React.createElement()` function, giving us expressiveness of JavaScript along with HTML like template syntax. + _JSX_ stands for _JavaScript XML_ and it is an XML-like syntax extension to ECMAScript. Basically it just provides the syntactic sugar for the `React.createElement(type, props, ...children)` function, giving us expressiveness of JavaScript along with HTML like template syntax. - In the example below text inside `

      ` tag is returned as JavaScript function to the render function. + In the example below, the text inside `

      ` tag is returned as JavaScript function to the render function. ```jsx harmony export default function App() { return ( -
      -

      {"This is a JSX Code!"}

      -
      +

      {"Hello, this is a JSX Code!"}

      + ); + } + ``` + If you don't use JSX syntax then the respective JavaScript code should be written as below, + + ```javascript + import { createElement } from 'react'; + + export default function App() { + return createElement( + 'h1', + { className: 'greeting' }, + 'Hello, this is a JSX Code!' ); } ``` @@ -431,9 +444,7 @@ class App extends React.Component { render() { return ( -
      -

      {"This is a JSX Code!"}

      -
      +

      {"Hello, this is a JSX Code!"}

      ); } } From 3d4681156b72ed90b31e0eb55a8263d3a555d6e1 Mon Sep 17 00:00:00 2001 From: Martin SCHNEIDER Date: Mon, 27 Mar 2023 16:32:26 +0200 Subject: [PATCH 033/149] Replace html tags with markdown tags --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 046cdb8a..242bbabc 100644 --- a/README.md +++ b/README.md @@ -7093,7 +7093,7 @@ const loadUser = async () => { State contains information or data about a component which may change over time. In class component, you can update the state when a user interacts with it or server updates the data using the `setState()` method. The initial state is going to be assigned in the `Constructor( ) `method using the the ` this.state` object and it is possible to different data types in the `this.state` object such as string, boolean, numbers, etc. - A simple example showing how we use the setState() and constructor() + ** A simple example showing how we use the setState() and constructor() ** ``` class App extends Component { From dfbb5f6ca7d0482ea2aa9a4903651ec07c6276df Mon Sep 17 00:00:00 2001 From: Martin SCHNEIDER Date: Mon, 27 Mar 2023 16:57:44 +0200 Subject: [PATCH 034/149] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 242bbabc..ee9ea950 100644 --- a/README.md +++ b/README.md @@ -7093,7 +7093,7 @@ const loadUser = async () => { State contains information or data about a component which may change over time. In class component, you can update the state when a user interacts with it or server updates the data using the `setState()` method. The initial state is going to be assigned in the `Constructor( ) `method using the the ` this.state` object and it is possible to different data types in the `this.state` object such as string, boolean, numbers, etc. - ** A simple example showing how we use the setState() and constructor() ** + **A simple example showing how we use the setState() and constructor()** ``` class App extends Component { From 41557803946b6deb1cf7b636ba458a6459bef4cb Mon Sep 17 00:00:00 2001 From: Martin SCHNEIDER Date: Mon, 27 Mar 2023 17:15:15 +0200 Subject: [PATCH 035/149] Fix some styling issues in q335 and q336 --- README.md | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index ee9ea950..5bbdb25c 100644 --- a/README.md +++ b/README.md @@ -7067,7 +7067,7 @@ const loadUser = async () => { The classs components uses ES6 classes to create the components. It uses `render` function to display the HTML content in the webpage. The syntax for class component looks like as below. - ``` + ```js class App extends Reacts.Component { render(){ return

      This is a class component

      } @@ -7079,7 +7079,7 @@ const loadUser = async () => { Functional component has been improved over the years with some added features like Hooks. Here is a syntax for functional component. - ``` + ```js function App(){ return

      Hello, I'm a function component

      @@ -7095,7 +7095,7 @@ const loadUser = async () => { In class component, you can update the state when a user interacts with it or server updates the data using the `setState()` method. The initial state is going to be assigned in the `Constructor( ) `method using the the ` this.state` object and it is possible to different data types in the `this.state` object such as string, boolean, numbers, etc. **A simple example showing how we use the setState() and constructor()** - ``` + ```js class App extends Component { constructor() { super(); @@ -7131,7 +7131,7 @@ const loadUser = async () => { Let's see an example to demonstrate the state in functional components, - ``` + ```js function App() { const [message, setMessage] = useState("This is a functional component"); const updateMessage = () => { @@ -7150,7 +7150,7 @@ const loadUser = async () => { Props are referred to as "properties". The props are passed into react component just like arguments passed to a function. In otherwords, they are similar to HTML attributes. The props are accessible in child class component using `this.props` as shown in below example, - ``` + ```js class Child extends React.Component { render() { return

      This is a functional component and component name is {this.props.name}

      ; @@ -7171,7 +7171,7 @@ const loadUser = async () => { Props in functional components are similar to that of the class components but the difference is the absence of 'this' keyword. - ``` + ```js function Child(props) { return

      This is a child component and the component name is{props.name}

      ; } @@ -7189,36 +7189,34 @@ const loadUser = async () => { **[⬆ Back to Top](#table-of-contents)** 336. ### Why does strict mode render twice in React? + StrictMode renders components twice in development mode(not production) in order to detect any problems with your code and warn you about those problems. This is used to detect accidental side effects in the render phase. If you used `create-react-app` development tool then it automatically enables StrictMode by default. - StrictMode renders components twice in development mode(not production) in order to detect any problems with your code and warn you about those problems. This is used to detect accidental side effects in the render phase. If you used `create-react-app` development tool then it automatically enables StrictMode by default. - - ```js + ```js ReactDOM.render( {App} , document.getElementById('root') ); - ``` + ``` - If you want to disable this behavior then you can remove `strict` mode. - ```js + If you want to disable this behavior then you can remove `strict` mode. + ```js ReactDOM.render( - {App}, + {App}, document.getElementById('root') ); - ``` - - To detect side effects the following functions are invoked twice: + ``` - 1. Class component constructor, render, and shouldComponentUpdate methods - 2. Class component static getDerivedStateFromProps method - 3. Function component bodies - 4. State updater functions - 5. Functions passed to useState, useMemo, or useReducer (any Hook) + To detect side effects the following functions are invoked twice: - **[⬆ Back to Top](#table-of-contents)** + 1. Class component constructor, render, and shouldComponentUpdate methods + 2. Class component static getDerivedStateFromProps method + 3. Function component bodies + 4. State updater functions + 5. Functions passed to useState, useMemo, or useReducer (any Hook) + **[⬆ Back to Top](#table-of-contents)** ## Disclaimer @@ -7227,4 +7225,3 @@ The questions provided in this repository are the summary of frequently asked qu Good luck with your interview 😊 --- -``` From 116fe4e02327783410155966b798fefea02efaa0 Mon Sep 17 00:00:00 2001 From: Martin SCHNEIDER Date: Mon, 27 Mar 2023 17:20:46 +0200 Subject: [PATCH 036/149] Fix indent of Back To Top links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5bbdb25c..40bf4e20 100644 --- a/README.md +++ b/README.md @@ -7186,7 +7186,7 @@ const loadUser = async () => { } ``` - **[⬆ Back to Top](#table-of-contents)** +**[⬆ Back to Top](#table-of-contents)** 336. ### Why does strict mode render twice in React? StrictMode renders components twice in development mode(not production) in order to detect any problems with your code and warn you about those problems. This is used to detect accidental side effects in the render phase. If you used `create-react-app` development tool then it automatically enables StrictMode by default. @@ -7216,7 +7216,7 @@ const loadUser = async () => { 4. State updater functions 5. Functions passed to useState, useMemo, or useReducer (any Hook) - **[⬆ Back to Top](#table-of-contents)** +**[⬆ Back to Top](#table-of-contents)** ## Disclaimer From 98917d983f4ef73d546cbf6b7356bbcdb209700b Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Tue, 28 Mar 2023 05:00:15 +0800 Subject: [PATCH 037/149] Update questions related to components --- README.md | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 046cdb8a..2537deaa 100644 --- a/README.md +++ b/README.md @@ -459,15 +459,15 @@ 4. ### What is the difference between Element and Component? - An _Element_ is a plain object describing what you want to appear on the screen in terms of the DOM nodes or other components. _Elements_ can contain other _Elements_ in their props. Creating a React element is cheap. Once an element is created, it is never mutated. + An _Element_ is a plain object describing what you want to appear on the screen in terms of the DOM nodes or other components. _Elements_ can contain other _Elements_ in their props. Creating a React element is cheap. Once an element is created, it cannot be mutated. - The object representation of React Element would be as follows: + The JavaScript representation of React Element would be as follows: ```javascript const element = React.createElement("div", { id: "login-btn" }, "Login"); ``` - The above `React.createElement()` function returns an object: + The above `React.createElement()` function returns an object as below: ``` { @@ -479,7 +479,7 @@ } ``` - And finally it renders to the DOM using `ReactDOM.render()`: + And finally this elements renders to the DOM using `ReactDOM.render()`: ```html
      Login
      @@ -488,8 +488,8 @@ Whereas a **component** can be declared in several different ways. It can be a class with a `render()` method or it can be defined as a function. In either case, it takes props as an input, and returns a JSX tree as the output: ```javascript - const Button = ({ onLogin }) => ( -
      + const Button = ({ handleLogin }) => ( +
      Login
      ); @@ -498,10 +498,10 @@ Then JSX gets transpiled to a `React.createElement()` function tree: ```javascript - const Button = ({ onLogin }) => + const Button = ({ handleLogin }) => React.createElement( "div", - { id: "login-btn", onClick: onLogin }, + { id: "login-btn", onClick: handleLogin }, "Login" ); ``` @@ -510,7 +510,7 @@ 5. ### How to create components in React? - There are two possible ways to create a component. + Components are the building blocks of creating User Interfaces(UI) in React. There are two possible ways to create a component. 1. **Function Components:** This is the simplest way to create a component. Those are pure JavaScript functions that accept props object as the first parameter and return React elements: @@ -520,7 +520,7 @@ } ``` - 2. **Class Components:** You can also use ES6 class to define a component. The above function component can be written as: + 2. **Class Components:** You can also use ES6 class to define a component. The above function component can be written as a class component: ```jsx harmony class Greeting extends React.Component { @@ -534,10 +534,26 @@ 6. ### When to use a Class Component over a Function Component? - If the component needs _state or lifecycle methods_ then use class component otherwise use function component. + After the addition of Hooks(i.e. React 16.8 onwards) it is always recommended to use Function components over Class components in React. Because you could use state, lifecycle methods and other features that were only available in class component present in function component too. + + But even there are two reasons to use Class components over Function components. + + 1. If you need a React functionality whose Function component equivalent is not present yet, like Error Boundaries. + 2. In older versions, If the component needs _state or lifecycle methods_ then you need to use class component. + - _However, from React 16.8 with the addition of Hooks, you could use state , lifecycle methods and other features that were only available in class component right in your function component._ - _So, it is always recommended to use Function components, unless you need a React functionality whose Function component equivalent is not present yet, like Error Boundaries._ + **Note:** You can also use reusable [react error boundary](https://github.com/bvaughn/react-error-boundary) third-party component without writing any class. i.e, No need to use class components for Error boundaries. + + The usage is quite straight forward. + ```jsx + "use client"; + + import { ErrorBoundary } from "react-error-boundary"; + + Something went wrong
      }> + + + ``` **[⬆ Back to Top](#table-of-contents)** From 3c03468f6d4d081cdf969a5d54f945727009597c Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Fri, 31 Mar 2023 18:15:54 +0800 Subject: [PATCH 038/149] Improve react fundamental questions --- README.md | 217 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 141 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index 2537deaa..8cb43468 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,6 @@

      ---- -

      - - Codestudio Logo - -

      - Explore the Best Free Resource to learn React and kickstart your journey as a react developer. Earn a free certification in just 40 days. -

      -

      - --- **Note:** This repository is specific to ReactJS. Please check [Javascript Interview questions](https://github.com/sudheerj/javascript-interview-questions) for core javascript questions. @@ -461,11 +451,16 @@ An _Element_ is a plain object describing what you want to appear on the screen in terms of the DOM nodes or other components. _Elements_ can contain other _Elements_ in their props. Creating a React element is cheap. Once an element is created, it cannot be mutated. - The JavaScript representation of React Element would be as follows: + The JavaScript representation(Without JSX) of React Element would be as follows: ```javascript const element = React.createElement("div", { id: "login-btn" }, "Login"); ``` + and this element can be simiplified using JSX + + ```html +
      Login
      + ``` The above `React.createElement()` function returns an object as below: @@ -479,11 +474,7 @@ } ``` - And finally this elements renders to the DOM using `ReactDOM.render()`: - - ```html -
      Login
      - ``` + Finally, this element renders to the DOM using `ReactDOM.render()`. Whereas a **component** can be declared in several different ways. It can be a class with a `render()` method or it can be defined as a function. In either case, it takes props as an input, and returns a JSX tree as the output: @@ -512,7 +503,7 @@ Components are the building blocks of creating User Interfaces(UI) in React. There are two possible ways to create a component. - 1. **Function Components:** This is the simplest way to create a component. Those are pure JavaScript functions that accept props object as the first parameter and return React elements: + 1. **Function Components:** This is the simplest way to create a component. Those are pure JavaScript functions that accept props object as the first parameter and return React elements to render the output: ```jsx harmony function Greeting({ message }) { @@ -544,7 +535,8 @@ **Note:** You can also use reusable [react error boundary](https://github.com/bvaughn/react-error-boundary) third-party component without writing any class. i.e, No need to use class components for Error boundaries. - The usage is quite straight forward. + The usage of Error boundaries from the above library is quite straight forward. + ```jsx "use client"; @@ -559,7 +551,49 @@ 7. ### What are Pure Components? - _`React.PureComponent`_ is exactly the same as _`React.Component`_ except that it handles the `shouldComponentUpdate()` method for you. When props or state changes, _PureComponent_ will do a shallow comparison on both props and state. _Component_ on the other hand won't compare current props and state to next out of the box. Thus, the component will re-render by default whenever `shouldComponentUpdate` is called. In functional components we use `React.memo()` API. `React.memo()` is a higher-order component. It takes a React component as its first argument and returns a special type of React component that allows the renderer to render the component while memoizing the output. Therefore, if the component’s props are shallowly equal, the `React.memo()` component will bail out the updates. + Pure components are the components which render the same output for the same state and props. In function components, you can achieve these pure components through memoized `React.memo()` API wrapping around the component. This API prevents unnecessary re-renders by comparing the previous props and new props using shallow comparison. So it will be helpful for performance optimizations. + + But at the same time, it won't compare the previous state with the current state because function component itself prevents the unnecessary rendering by default when you set the same state again. + + The syntactic representation of memoized components looks like below, + + ```jsx + const MemoizedComponent = memo(SomeComponent, arePropsEqual?); + ``` + + Below is the example of how child component(i.e., EmployeeProfile) prevents re-renders for the same props passed by parent component(i.e.,EmployeeRegForm). + + ```jsx + import { memo, useState } from 'react'; + + const EmployeeProfile = memo(function EmployeeProfile({ name, email }) { + return (<> +

      Name:{name}

      +

      Email: {email}

      + ); + }); + export default function EmployeeRegForm() { + const [name, setName] = useState(''); + const [email, setEmail] = useState(''); + return ( + <> + + +
      + + + ); + } + ``` + In the above code, the email prop has not been passed to child component. So there won't be any re-renders for email prop change. + + In class components, the components extending _`React.PureComponent`_ instead of _`React.Component`_ become the pure components. When props or state changes, _PureComponent_ will do a shallow comparison on both props and state by invoking `shouldComponentUpdate()` lifecycle method. + + **Note:** `React.memo()` is a higher-order component. **[⬆ Back to Top](#table-of-contents)** @@ -617,7 +651,7 @@ 9. ### What are props in React? - _Props_ are inputs to components. They are single values or objects containing a set of values that are passed to components on creation similar to HTML-tag attributes. They are data passed down from a parent component to a child component. + _Props_ are inputs to components. They are single values or objects containing a set of values that are passed to components on creation similar to HTML-tag attributes. Here, the data is passed down from a parent component to a child component. The primary purpose of props in React is to provide following component functionality: @@ -631,42 +665,13 @@ ``` - This `reactProp` (or whatever you came up with) name then becomes a property attached to React's native props object which originally already exists on all components created using React library. + This `reactProp` (or whatever you came up with) attribute name then becomes a property attached to React's native props object which originally already exists on all components created using React library. - ``` + ```jsx harmony props.reactProp ``` - **Example: Props in Class Based Component** - - ```jsx - import React from "react"; - import ReactDOM from "react-dom"; - - class ChildComponent extends React.Component { - render() { - return ( -
      -

      {this.props.name}

      -

      {this.props.age}

      -
      - ); - } - } - - class ParentComponent extends React.Component { - render() { - return ( -
      - - -
      - ); - } - } - ``` - - **Example: Props in Functional Component** + For example, the usage of props in function component looks like below: ```jsx import React from "react"; @@ -691,6 +696,52 @@ }; ``` + The properties from props object can be accessed directly using destructing feature from ES6 (ECMAScript 2015). The above child component can be simplified like below. + + ```jsx harmony + const ChildComponent = ({name, age}) => { + return ( +
      +

      {name}

      +

      {age}

      +
      + ); + }; + ``` + +
      See Class +

      + The Props accessed in Class Based Component as below + + ```jsx + import React from "react"; + import ReactDOM from "react-dom"; + + class ChildComponent extends React.Component { + render() { + return ( +

      +

      {this.props.name}

      +

      {this.props.age}

      +
      + ); + } + } + + class ParentComponent extends React.Component { + render() { + return ( +
      + + +
      + ); + } + } + ``` +

      +
      + **[⬆ Back to Top](#table-of-contents)** 10. ### What is the difference between state and props? @@ -1434,7 +1485,7 @@ 45. ### Why React uses `className` over `class` attribute? - `class` is a keyword in JavaScript, and JSX is an extension of JavaScript. That's the principal reason why React uses `className` instead of `class`. Pass a string as the `className` prop. + The attribute `class` is a keyword in JavaScript, and JSX is an extension of JavaScript. That's the principal reason why React uses `className` instead of `class`. Pass a string as the `className` prop. ```jsx harmony render() { @@ -1446,31 +1497,47 @@ 46. ### What are fragments? - It's a common pattern in React which is used for a component to return multiple elements. _Fragments_ let you group a list of children without adding extra nodes to the DOM. + It's a common pattern or practice in React for a component to return multiple elements. _Fragments_ let you group a list of children without adding extra nodes to the DOM. + You need to use either **** or a shorter syntax having empty tag (**<>**). + Below is the example of how to use fragment inside _Story_ component. ```jsx harmony - render() { + function Story({title, description, date}) { return ( - - - - - - ) + +

      {title}

      +

      {description}

      +

      {date}

      + + ); } ``` - There is also a _shorter syntax_, but it's not supported in many tools: + It is also possible to render list of fragments inside a loop with the mandatory **key** attribute supplied. ```jsx harmony - render() { + function StoryBook() { + return stories.map(story => + +

      {story.title}

      +

      {story.description}

      +

      {story.date}

      +
      + ); + } + ``` + + Ususally you don't need to use **** until unless there is a need of _key_ attribute. The usage of shorter syntax looks like below. + + ```jsx harmony + function Story({title, description, date}) { return ( - <> - - - - - ) + <> +

      {title}

      +

      {description}

      +

      {date}

      + + ); } ``` @@ -1478,7 +1545,7 @@ 47. ### Why fragments are better than container divs? - Below are the list of reasons, + Below are the list of reasons to prefer fragments over container DOM elements, 1. Fragments are a bit faster and use less memory by not creating an extra DOM node. This only has a real benefit on very large and deep trees. 2. Some CSS mechanisms like _Flexbox_ and _CSS Grid_ have a special parent-child relationships, and adding divs in the middle makes it hard to keep the desired layout. @@ -5263,12 +5330,12 @@ 242. ### What are default props? - The defaultProps are defined as a property on the component class to set the default props for the class. This is used for undefined props, but not for null props. + The _defaultProps_ can be defined as a property on the component to set the default values for the props. These default props are used when props not supplied(i.e., undefined props), but not for null props. That means, If you provide null value then it remains null value. For example, let us create color default prop for the button component, ```javascript - class MyButton extends React.Component { + function MyButton { // ... } @@ -5277,16 +5344,14 @@ }; ``` - If `props.color` is not provided then it will set the default value to 'red'. i.e, Whenever you try to access the color prop it uses default value + If `props.color` is not provided then it will set the default value to 'red'. i.e, Whenever you try to access the color prop it uses the default value ```javascript render() { - return ; // props.color will be set to red + return ; // props.color will contain red value } ``` - **Note:** If you provide null value then it remains null value. - **[⬆ Back to Top](#table-of-contents)** 243. ### Why should not call setState in componentWillUnmount? From 4b91fc1b27371b9c8736317264ee1048e46a05be Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Tue, 4 Apr 2023 18:24:36 +0800 Subject: [PATCH 039/149] Update hooks question description and rules --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e0527b04..903d6317 100644 --- a/README.md +++ b/README.md @@ -5093,7 +5093,7 @@ 226. ### What are hooks? - Hooks is a special function (introduced as a new feature in React 16.8) that lets you use state and other React features without writing a class. + Hooks is a special JavaScript function that allows you use state and other React features without writing a class. This pattern has been introduced as a new feature in React 16.8 and helped to isolate the stateful logic from the components. Let's see an example of useState hook: @@ -5105,15 +5105,15 @@ const [count, setCount] = useState(0); return ( -
      + <>

      You clicked {count} times

      -
      + ); } ``` - **Note:** Hooks can be used inside an existing function component. + **Note:** Hooks can be used inside an existing function component without rewriting the component. **[⬆ Back to Top](#table-of-contents)** @@ -5121,8 +5121,10 @@ You need to follow two rules in order to use hooks, - 1. Call Hooks only at the top level of your react functions. i.e, You shouldn’t call Hooks inside loops, conditions, or nested functions. This will ensure that Hooks are called in the same order each time a component renders and it preserves the state of Hooks between multiple useState and useEffect calls. - 2. Call Hooks from React Functions only. i.e, You shouldn’t call Hooks from regular JavaScript functions. + 1. **Call Hooks only at the top level of your react functions:** You shouldn’t call Hooks inside loops, conditions, or nested functions. This will ensure that Hooks are called in the same order each time a component renders and it preserves the state of Hooks between multiple useState and useEffect calls. + 2. **Call Hooks from React Functions only:**You shouldn’t call Hooks from regular JavaScript functions. Instead, you should call them from either function components or custom hooks. + + The eslint plugin named **eslint-plugin-react-hooks** can be used to enforce these two rules. **[⬆ Back to Top](#table-of-contents)** From bd935820775037d59963ca9f46144ea8a1f3832b Mon Sep 17 00:00:00 2001 From: Chetan Nada Date: Sat, 8 Apr 2023 01:40:08 +0530 Subject: [PATCH 040/149] Added easy and meaningful Answer of Reconciliation Process --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 903d6317..c4240568 100644 --- a/README.md +++ b/README.md @@ -1416,7 +1416,9 @@ 41. ### What is reconciliation? - When a component's props or state change, React decides whether an actual DOM update is necessary by comparing the newly returned element with the previously rendered one. When they are not equal, React will update the DOM. This process is called _reconciliation_. + `Reconciliation` is the process through which React updates the Browser DOM and makes React work faster. React use a `diffing algorithm` so that component updates are predictable and faster. React would first calculate the difference between the `real DOM` and the copy of DOM `(Virtual DOM)` when there's an update of components. + React stores a copy of Browser DOM which is called `Virtual DOM`. When we make changes or add data, React creates a new Virtual DOM and compares it with the previous one. This comparison is done by `Diffing Algorithm`. + Now React compares the Virtual DOM with Real DOM. It finds out the changed nodes and updates only the changed nodes in Real DOM leaving the rest nodes as it is. This process is called _Reconciliation_. **[⬆ Back to Top](#table-of-contents)** From d352487c88f03bb772d78683e5755beda9386986 Mon Sep 17 00:00:00 2001 From: Marcelo Henrique da Silva Fonseca Date: Mon, 10 Apr 2023 14:28:14 -0300 Subject: [PATCH 041/149] Fixing the duplicated word in question #10 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 903d6317..11bd30e8 100644 --- a/README.md +++ b/README.md @@ -744,7 +744,7 @@ 10. ### What is the difference between state and props? - In React, both `state` and `props` are are plain JavaScript objects and used to manage the data of a component, but they are used in different ways and have different characteristics. + In React, both `state` and `props` are plain JavaScript objects and used to manage the data of a component, but they are used in different ways and have different characteristics. `state` is managed by the component itself and can be updated using the `setState()` function. Unlike props, state can be modified by the component and is used to manage the internal state of the component. Changes in the state trigger a re-render of the component and its children. `props` (short for "properties") are passed to a component by its parent component and are `read-only`, meaning that they cannot be modified by the component itself. props can be used to configure the behavior of a component and to pass data between components. From f27613e917464be0d0ec8bba86082db0b3b915e6 Mon Sep 17 00:00:00 2001 From: MidhaTahir Date: Tue, 11 Apr 2023 02:02:17 +0500 Subject: [PATCH 042/149] fixing tab issue to have code and text separately --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 903d6317..64791d9a 100644 --- a/README.md +++ b/README.md @@ -1511,7 +1511,7 @@ } ``` - It is also possible to render list of fragments inside a loop with the mandatory **key** attribute supplied. + It is also possible to render list of fragments inside a loop with the mandatory **key** attribute supplied. ```jsx harmony function StoryBook() { From 010b1b64ee6a13a00ba815f8134f4627ed454eeb Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Wed, 12 Apr 2023 19:59:05 +0800 Subject: [PATCH 043/149] Added React import --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 480907e7..ff44b5cb 100644 --- a/README.md +++ b/README.md @@ -623,6 +623,7 @@

      ```jsx harmony + import React from 'react'; class User extends React.Component { constructor(props) { super(props); From 7932c58b88ac289337eaa375081ba7a94f7940ad Mon Sep 17 00:00:00 2001 From: Marcelo Henrique da Silva Fonseca Date: Wed, 12 Apr 2023 13:27:21 -0300 Subject: [PATCH 044/149] correcting example of using --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ff44b5cb..84ef3dde 100644 --- a/README.md +++ b/README.md @@ -1509,7 +1509,7 @@

      {title}

      {description}

      {date}

      - +
      ); } ``` From 3518b5f490e013bcdbc6fa7f71e48da95ff8893b Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sun, 16 Apr 2023 10:17:01 +0800 Subject: [PATCH 045/149] Coding exercise for ref usage --- coding-exercise/README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/coding-exercise/README.md b/coding-exercise/README.md index 7339d202..31c8d507 100644 --- a/coding-exercise/README.md +++ b/coding-exercise/README.md @@ -188,3 +188,42 @@ This issue can be fixed by wrapping the **** component with `fo **[⬆ Back to Top](#table-of-contents)** +#### 5. What is the outcome of number of clicks after 3 button clicks? + +```javascript +import { useRef } from 'react'; + +export default function Counter() { + let ref = useRef(0); + + function handleClick() { + ref.current = ref.current + 1; + } + + return ( + <> +
      Clicked + {ref.current} + times
      + + + ); +} +``` + +- 1: 3 times +- 2: 4 times +- 3: 2 times +- 4: 0 times + +
      Answer +

      + +##### Answer: 4 +If you try to use **{ref.current}** in the render method, the number won’t be updated on click. This is because **ref.current** does not trigger a re-render unlike state. This property is mainly used to read and write the values inside event handler or outside the render method. +

      +
      + +--- + +**[⬆ Back to Top](#table-of-contents)** \ No newline at end of file From 0f4c40d66e88c3327e53e3a4311569219df39743 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Tue, 18 Apr 2023 19:35:57 +0800 Subject: [PATCH 046/149] Update answers of hook rules and linting --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 84ef3dde..0eec1d3d 100644 --- a/README.md +++ b/README.md @@ -5125,7 +5125,7 @@ You need to follow two rules in order to use hooks, 1. **Call Hooks only at the top level of your react functions:** You shouldn’t call Hooks inside loops, conditions, or nested functions. This will ensure that Hooks are called in the same order each time a component renders and it preserves the state of Hooks between multiple useState and useEffect calls. - 2. **Call Hooks from React Functions only:**You shouldn’t call Hooks from regular JavaScript functions. Instead, you should call them from either function components or custom hooks. + 2. **Call Hooks from React Functions only:** You shouldn’t call Hooks from regular JavaScript functions. Instead, you should call them from either function components or custom hooks. The eslint plugin named **eslint-plugin-react-hooks** can be used to enforce these two rules. @@ -5150,6 +5150,9 @@ } } ``` + + For example, the linter enforce proper naming convention for hooks. If you rename your custom hooks which as prefix "use" to something else then linter won't allow you to call built-in hooks such as useState, useEffect etc inside of your custom hook anymore. + **Note:** This plugin is intended to use in Create React App by default. **[⬆ Back to Top](#table-of-contents)** From 2484dfe5cdd4fd09f46394a285c54a6ac4b0a06d Mon Sep 17 00:00:00 2001 From: Abhay S Nath Date: Thu, 20 Apr 2023 21:06:20 +0530 Subject: [PATCH 047/149] Update App.js --- coding-exercise/src/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coding-exercise/src/App.js b/coding-exercise/src/App.js index ce9cbd29..015b924f 100644 --- a/coding-exercise/src/App.js +++ b/coding-exercise/src/App.js @@ -8,7 +8,7 @@ function App() {
      logo

      - Edit src/App.js and save to reload. + Edit src/App.js and save to reload browser.

      Date: Wed, 24 May 2023 21:56:23 +0530 Subject: [PATCH 048/149] Detailed Answer added with example in Question 218 --- README.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0eec1d3d..5efaf5d6 100644 --- a/README.md +++ b/README.md @@ -4917,13 +4917,25 @@ 218. ### How to pass numbers to React component? - You should be passing the numbers via curly braces({}) where as strings in quotes + We can pass `numbers` as `props` to React component using curly braces `{}` where as `strings` in double quotes `""` or single quotes `''` ```jsx - React.render( - , - document.getElementById("container") - ); + import React from "react"; + const ChildComponent = ({ name, age }) => { + return ( + <> + My Name is {name} and Age is {age} + + ); + }; + const ParentComponent = () => { + return ( + <> + + + ); + }; + export default ParentComponent; ``` **[⬆ Back to Top](#table-of-contents)** From 0e2b84a264d1a95c1c6a73609579f63575c12397 Mon Sep 17 00:00:00 2001 From: Ali Varaste Pour Date: Wed, 26 Jul 2023 14:48:47 +0330 Subject: [PATCH 049/149] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0eec1d3d..fcc37745 100644 --- a/README.md +++ b/README.md @@ -939,7 +939,7 @@ 18. ### What is "key" prop and what is the benefit of using it in arrays of elements? - A `key` is a special attribute you **should** include when creating arrays of elements. _Key_ prop helps React identify which items have changed, are added, or are removed. + A `key` is a special attribute you **should** include when mapping over arrays to render data. _Key_ prop helps React identify which items have changed, are added, or are removed. Keys should be unique among its siblings. Most often we use ID from our data as _key_: From a4901aa5b704c852270d0c3055e1df4edccfd20b Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sat, 16 Sep 2023 14:34:59 +0800 Subject: [PATCH 050/149] Reorder strict mode --- README.md | 91 +++++++++++++++++++++++++------------------------------ 1 file changed, 42 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 0eec1d3d..d4907a7b 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,6 @@ | 80 | [What is the recommended ordering of methods in component class?](#what-is-the-recommended-ordering-of-methods-in-component-class) | | 81 | [What is a switching component?](#what-is-a-switching-component) | | 82 | [Why we need to pass a function to setState()?](#why-we-need-to-pass-a-function-to-setstate) | -| 83 | [What is strict mode in React?](#what-is-strict-mode-in-react) | | 84 | [What are React Mixins?](#what-are-react-mixins) | | 85 | [Why is isMounted() an anti-pattern and what is the proper solution?](#why-is-ismounted-an-anti-pattern-and-what-is-the-proper-solution) | | 86 | [What are the Pointer Events supported in React?](#what-are-the-pointer-events-supported-in-react) | @@ -365,7 +364,8 @@ | 333 | [What is a wrapper component ](#what-is-a-wrapper-component) | | 334 | [What are the differences between useEffect and useLayoutEffect hooks](#what-are-the-differences-between-useEffect-and-useLayoutEffect-hooks) | | 335 | [What are the differences between Functional and Class Components ](#what-are-the-differences-between-functional-and-class-components) | -| 336 | [Why does strict mode render twice in React?](#why-does-strict-mode-render-twice-in-react) | +| 336 | [What is strict mode in React?](#what-is-strict-mode-in-react) | +| 338 | [Why does strict mode render twice in React?](#why-does-strict-mode-render-twice-in-react) | ## Core React @@ -2309,41 +2309,6 @@ **[⬆ Back to Top](#table-of-contents)** -83. ### What is strict mode in React? - - `React.StrictMode` is a useful component for highlighting potential problems in an application. Just like ``, `` does not render any extra DOM elements. It activates additional checks and warnings for its descendants. These checks apply for _development mode_ only. - - ```jsx harmony - import React from "react"; - - function ExampleApplication() { - return ( -
      -
      - -
      - - -
      -
      -
      -
      - ); - } - ``` - - In the example above, the _strict mode_ checks apply to `` and `` components only. - - React.StrictMode currently helps you with: - - 1. Identifying components with unsafe lifecycles - 2. Warning about legacy string ref API usage - 3. Warning about deprecated `findDOMNode` usage - 4. Detecting unexpected side effects - 5. Detecting legacy context API - - **[⬆ Back to Top](#table-of-contents)** - 84. ### What are React Mixins? _Mixins_ are a way to totally separate components to have a common functionality. Mixins **should not be used** and can be replaced with _higher-order components_ or _decorators_. @@ -5508,18 +5473,6 @@ **[⬆ Back to Top](#table-of-contents)** -251. ### What is the benefit of strict mode? - - The will be helpful in the below cases - - 1. Identifying components with **unsafe lifecycle methods**. - 2. Warning about **legacy string ref** API usage. - 3. Detecting unexpected **side effects**. - 4. Detecting **legacy context** API. - 5. Warning about deprecated findDOMNode usage - -**[⬆ Back to Top](#table-of-contents)** - 252. ### What are Keyed Fragments? The Fragments declared with the explicit syntax may have keys. The general use case is mapping a collection to an array of fragments as below, @@ -7275,6 +7228,46 @@ const loadUser = async () => { **[⬆ Back to Top](#table-of-contents)** +336. ### What is strict mode in React? + + `React.StrictMode` is a useful component for highlighting potential problems in an application. Just like ``, `` does not render any extra DOM elements. It activates additional checks and warnings for its descendants. These checks apply for _development mode_ only. + + ```jsx harmony + import React from "react"; + + function ExampleApplication() { + return ( +
      +
      + +
      + + +
      +
      +
      +
      + ); + } + ``` + + In the example above, the _strict mode_ checks apply to `` and `` components only. i.e., Part of the application only. + + **[⬆ Back to Top](#table-of-contents)** + +337. ### What is the benefit of strict mode? + + The will be helpful in the below cases, + 1. Whenever the component + + 1. Identifying components with **unsafe lifecycle methods**. + 2. Warning about **legacy string ref** API usage. + 3. Detecting unexpected **side effects**. + 4. Detecting **legacy context** API. + 5. Warning about deprecated findDOMNode usage + +**[⬆ Back to Top](#table-of-contents)** + 336. ### Why does strict mode render twice in React? StrictMode renders components twice in development mode(not production) in order to detect any problems with your code and warn you about those problems. This is used to detect accidental side effects in the render phase. If you used `create-react-app` development tool then it automatically enables StrictMode by default. From f840de79c2111bf683e796831417d4023f13a042 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sat, 16 Sep 2023 16:55:03 +0800 Subject: [PATCH 051/149] Add uidev sponsor --- README.md | 9 +++++ images/collab/codestudio-logo.svg | 55 ------------------------------ images/collab/uidev-banner2x.png | Bin 0 -> 33072 bytes images/collab/uidev-banner4x.png | Bin 0 -> 74230 bytes 4 files changed, 9 insertions(+), 55 deletions(-) delete mode 100644 images/collab/codestudio-logo.svg create mode 100644 images/collab/uidev-banner2x.png create mode 100644 images/collab/uidev-banner4x.png diff --git a/README.md b/README.md index d113ab87..a551ceb6 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,15 @@

    +--- + + --- **Note:** This repository is specific to ReactJS. Please check [Javascript Interview questions](https://github.com/sudheerj/javascript-interview-questions) for core javascript questions. diff --git a/images/collab/codestudio-logo.svg b/images/collab/codestudio-logo.svg deleted file mode 100644 index 04cc5b29..00000000 --- a/images/collab/codestudio-logo.svg +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/images/collab/uidev-banner2x.png b/images/collab/uidev-banner2x.png new file mode 100644 index 0000000000000000000000000000000000000000..990d5a13e38dab5520d1b693cc7a457a343f160b GIT binary patch literal 33072 zcmX`R1yozn@;w|}3&l!t2-4!kt!Qy~m*5tpK!5_FxN9ly?hv537k6)hx464g=*RoL z|NFACvQBdEI%m(!o;_#oNu;`}+$(HyYybf8Nc=Ho1QQ0LV}3 z%Gxq7U+HORDapv`sHizum<{zboWYhazr4IHK>9#xnwNo@iJky2x7%ksRb@GlsqV`? z{{HTs9u6;;q$Nf5bW~pkGE!pt+N#!;MzoYv_^Kk^Wk1Rl2CKFKR0C8#@!O&Q<~D3|1h6uprMy zSgxs&w$B%52~lA&P9kFijfPN$sgWN%A2@&vz>A}~SO*4a3DG1M;3}fGx+G&l;?KTWYCeKV+B$a z6ehVim{Vz(zslD8Y|0O0X6IpJCyl6#fg00^$gJAG`xY1Y68hxS2!bG`?&h>uFf)ye zW~dc?EEGbfCE%p-7Vo~WWTzgH7btotW56mPAT6Nj?{0iL z)EZzQsm=dUkWZ9wTBQkQmQSVjc6w!IRQ7qVT`tjq@7RNK` zn&`upz0I$-CWUv-;B__p!=IcZpHR%YP^pn#5dG(M6O0r-w*49a0G*P%;x5K5YLOUx zV>uysxqd_L$Wu;|GT#<7#sUEJP|tjuKXx9BZ;BUL>GRCg0ssR34IY>)h=TRDD&{qU z%lPUVW)}iTD5X$)lK%?uoAUEw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ix update state for Q335 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a551ceb6..cb1a2bf0 100644 --- a/README.md +++ b/README.md @@ -7184,7 +7184,7 @@ const loadUser = async () => { function App() { const [message, setMessage] = useState("This is a functional component"); const updateMessage = () => { - setCountry("Updating the functional component"); + setMessage("Updating the functional component"); }; return (

    From 0bd6a46ab29541553ef5b0de65d3c02b32062321 Mon Sep 17 00:00:00 2001 From: Tyler McGinnis Date: Sun, 17 Sep 2023 10:41:07 -0600 Subject: [PATCH 053/149] Update README.md --- README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cb1a2bf0..f0280bf2 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,17 @@ > Click :star:if you like the project. Pull Request are highly appreciated. Follow me [@SudheerJonna](https://twitter.com/SudheerJonna) for technical updates. --- + +
    +

    + + React interview + +

    +
    + +--- + ---- - - --- **Note:** This repository is specific to ReactJS. Please check [Javascript Interview questions](https://github.com/sudheerj/javascript-interview-questions) for core javascript questions. From f4722e7ec3e4a54d31f757f0f9bb20f6fb75fc10 Mon Sep 17 00:00:00 2001 From: Umesh <138206213+Umesh-WW@users.noreply.github.com> Date: Sat, 7 Oct 2023 10:48:55 +0530 Subject: [PATCH 054/149] Quetion 3 : coding typo react fragment needs to have closing pair --- coding-exercise/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coding-exercise/README.md b/coding-exercise/README.md index 31c8d507..e7ff7b8a 100644 --- a/coding-exercise/README.md +++ b/coding-exercise/README.md @@ -111,7 +111,7 @@ export default function Counter() { - <> + } ``` @@ -226,4 +226,4 @@ If you try to use **{ref.current}** in the render method, the number won’t be --- -**[⬆ Back to Top](#table-of-contents)** \ No newline at end of file +**[⬆ Back to Top](#table-of-contents)** From ad55d7df73ac21901f49ada2d05d54ab2b2c3225 Mon Sep 17 00:00:00 2001 From: Ajay Prakash PP Date: Sat, 16 Dec 2023 01:25:07 +0530 Subject: [PATCH 055/149] Answer for Q4 : Apply JavaScript syntax highlighting to code block --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0280bf2..c91637f8 100644 --- a/README.md +++ b/README.md @@ -475,7 +475,7 @@ The above `React.createElement()` function returns an object as below: - ``` + ```javascript { type: 'div', props: { From 53a06abb364b0106072fbe9cbdca48a30275d7b2 Mon Sep 17 00:00:00 2001 From: Ajay Prakash PP Date: Sat, 16 Dec 2023 14:04:24 +0530 Subject: [PATCH 056/149] Added a note about using react-error-boundary in client components to clarify restrictions on props. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c91637f8..143a9ebd 100644 --- a/README.md +++ b/README.md @@ -547,6 +547,7 @@ **Note:** You can also use reusable [react error boundary](https://github.com/bvaughn/react-error-boundary) third-party component without writing any class. i.e, No need to use class components for Error boundaries. The usage of Error boundaries from the above library is quite straight forward. + >**_Note when using react-error-boundary:_** ErrorBoundary is a client component. You can only pass props to it that are serializeable or use it in files that have a "use client"; directive. ```jsx "use client"; From 06cd3de8c67640cf51cdb61f99c499c96085ebef Mon Sep 17 00:00:00 2001 From: "vikas.singh" Date: Mon, 25 Dec 2023 15:50:39 +0400 Subject: [PATCH 057/149] fix(typo): corrected the spelling of principle according to the context of statement --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c91637f8..95d143a2 100644 --- a/README.md +++ b/README.md @@ -1497,7 +1497,7 @@ 45. ### Why React uses `className` over `class` attribute? - The attribute `class` is a keyword in JavaScript, and JSX is an extension of JavaScript. That's the principal reason why React uses `className` instead of `class`. Pass a string as the `className` prop. + The attribute `class` is a keyword in JavaScript, and JSX is an extension of JavaScript. That's the principle reason why React uses `className` instead of `class`. Pass a string as the `className` prop. ```jsx harmony render() { From d5df7be087f0cfa1c8d0ee11905666c2b324154d Mon Sep 17 00:00:00 2001 From: Ajay Prakash PP Date: Mon, 1 Jan 2024 12:42:36 +0530 Subject: [PATCH 058/149] Q.7 changed "use client" inside note to code block. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1805f7e3..19aafb53 100644 --- a/README.md +++ b/README.md @@ -547,7 +547,7 @@ **Note:** You can also use reusable [react error boundary](https://github.com/bvaughn/react-error-boundary) third-party component without writing any class. i.e, No need to use class components for Error boundaries. The usage of Error boundaries from the above library is quite straight forward. - >**_Note when using react-error-boundary:_** ErrorBoundary is a client component. You can only pass props to it that are serializeable or use it in files that have a "use client"; directive. + >**_Note when using react-error-boundary:_** ErrorBoundary is a client component. You can only pass props to it that are serializeable or use it in files that have a `"use client";` directive. ```jsx "use client"; From 19d335b699a2277ff96d09ea3297c00dfea78cfa Mon Sep 17 00:00:00 2001 From: PIYUSH NEGI <43876655+npiyush97@users.noreply.github.com> Date: Tue, 2 Jan 2024 14:01:58 +0530 Subject: [PATCH 059/149] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1805f7e3..655fe9c5 100644 --- a/README.md +++ b/README.md @@ -857,7 +857,7 @@ } ``` - 2. **Public class fields syntax:** If you don't like to use bind approach then _public class fields syntax_ can be used to correctly bind callbacks. The Create React App eanables this syntax by default. + 2. **Public class fields syntax:** If you don't like to use bind approach then _public class fields syntax_ can be used to correctly bind callbacks. The Create React App enables this syntax by default. ```jsx harmony handleClick = () => { From a08b3fe3d5d005ecf30e461617e8e5d1423b0be8 Mon Sep 17 00:00:00 2001 From: Ma'ruf <72617743+MarufZak@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:57:22 +0500 Subject: [PATCH 060/149] Explain the reason for using React.portal --- README.md | 71 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 98b6f8e9..5b305e0d 100644 --- a/README.md +++ b/README.md @@ -1568,7 +1568,8 @@ 48. ### What are portals in React? - _Portal_ is a recommended way to render children into a DOM node that exists outside the DOM hierarchy of the parent component. + _Portal_ is a recommended way to render children into a DOM node that exists outside the DOM hierarchy of the parent component. When using + CSS transform in a component, its descendant elements should not use fixed positioning, otherwise the layout will blow up. ```javascript ReactDOM.createPortal(child, container); @@ -1578,13 +1579,13 @@ **[⬆ Back to Top](#table-of-contents)** -49. ### What are stateless components? +50. ### What are stateless components? If the behaviour of a component is independent of its state then it can be a stateless component. You can use either a function or a class for creating stateless components. But unless you need to use a lifecycle hook in your components, you should go for function components. There are a lot of benefits if you decide to use function components here; they are easy to write, understand, and test, a little faster, and you can avoid the `this` keyword altogether. **[⬆ Back to Top](#table-of-contents)** -50. ### What are stateful components? +51. ### What are stateful components? If the behaviour of a component is dependent on the _state_ of the component then it can be termed as stateful component. These _stateful components_ are either function components with hooks or _class components_. @@ -1636,7 +1637,7 @@ **[⬆ Back to Top](#table-of-contents)** -51. ### How to apply validation on props in React? +52. ### How to apply validation on props in React? When the application is running in _development mode_, React will automatically check all props that we set on components to make sure they have _correct type_. If the type is incorrect, React will generate warning messages in the console. It's disabled in _production mode_ due to performance impact. The mandatory props are defined with `isRequired`. @@ -1701,7 +1702,7 @@ **[⬆ Back to Top](#table-of-contents)** -52. ### What are the advantages of React? +53. ### What are the advantages of React? Below are the list of main advantages of React, @@ -1713,7 +1714,7 @@ **[⬆ Back to Top](#table-of-contents)** -53. ### What are the limitations of React? +54. ### What are the limitations of React? Apart from the advantages, there are few limitations of React too, @@ -1725,7 +1726,7 @@ **[⬆ Back to Top](#table-of-contents)** -54. ### What are error boundaries in React v16? +55. ### What are error boundaries in React v16? _Error boundaries_ are components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of the component tree that crashed. @@ -1768,19 +1769,19 @@ **[⬆ Back to Top](#table-of-contents)** -55. ### How are error boundaries handled in React v15? +56. ### How are error boundaries handled in React v15? React v15 provided very basic support for _error boundaries_ using `unstable_handleError` method. It has been renamed to `componentDidCatch` in React v16. **[⬆ Back to Top](#table-of-contents)** -56. ### What are the recommended ways for static type checking? +57. ### What are the recommended ways for static type checking? Normally we use _PropTypes library_ (`React.PropTypes` moved to a `prop-types` package since React v15.5) for _type checking_ in the React applications. For large code bases, it is recommended to use _static type checkers_ such as Flow or TypeScript, that perform type checking at compile time and provide auto-completion features. **[⬆ Back to Top](#table-of-contents)** -57. ### What is the use of `react-dom` package? +58. ### What is the use of `react-dom` package? The `react-dom` package provides _DOM-specific methods_ that can be used at the top level of your app. Most of the components are not required to use this module. Some of the methods of this package are: @@ -1792,7 +1793,7 @@ **[⬆ Back to Top](#table-of-contents)** -58. ### What is the purpose of render method of `react-dom`? +59. ### What is the purpose of render method of `react-dom`? This method is used to render a React element into the DOM in the supplied container and return a reference to the component. If the React element was previously rendered into container, it will perform an update on it and only mutate the DOM as necessary to reflect the latest changes. @@ -1804,7 +1805,7 @@ **[⬆ Back to Top](#table-of-contents)** -59. ### What is ReactDOMServer? +60. ### What is ReactDOMServer? The `ReactDOMServer` object enables you to render components to static markup (typically used on node server). This object is mainly used for _server-side rendering_ (SSR). The following methods can be used in both the server and browser environments: @@ -1831,7 +1832,7 @@ **[⬆ Back to Top](#table-of-contents)** -60. ### How to use innerHTML in React? +61. ### How to use innerHTML in React? The `dangerouslySetInnerHTML` attribute is React's replacement for using `innerHTML` in the browser DOM. Just like `innerHTML`, it is risky to use this attribute considering cross-site scripting (XSS) attacks. You just need to pass a `__html` object as key and HTML text as value. @@ -1849,7 +1850,7 @@ **[⬆ Back to Top](#table-of-contents)** -61. ### How to use styles in React? +62. ### How to use styles in React? The `style` attribute accepts a JavaScript object with camelCased properties rather than a CSS string. This is consistent with the DOM style JavaScript property, is more efficient, and prevents XSS security holes. @@ -1868,7 +1869,7 @@ **[⬆ Back to Top](#table-of-contents)** -62. ### How events are different in React? +63. ### How events are different in React? Handling events in React elements has some syntactic differences: @@ -1877,13 +1878,13 @@ **[⬆ Back to Top](#table-of-contents)** -63. ### What will happen if you use `setState()` in constructor? +64. ### What will happen if you use `setState()` in constructor? When you use `setState()`, then apart from assigning to the object state React also re-renders the component and all its children. You would get error like this: _Can only update a mounted or mounting component._ So we need to use `this.state` to initialize variables inside constructor. **[⬆ Back to Top](#table-of-contents)** -64. ### What is the impact of indexes as keys? +65. ### What is the impact of indexes as keys? Keys should be stable, predictable, and unique so that React can keep track of elements. @@ -1905,7 +1906,7 @@ **[⬆ Back to Top](#table-of-contents)** -65. ### Is it good to use `setState()` in `componentWillMount()` method? +66. ### Is it good to use `setState()` in `componentWillMount()` method? Yes, it is safe to use `setState()` inside `componentWillMount()` method. But at the same it is recommended to avoid async initialization in `componentWillMount()` lifecycle method. `componentWillMount()` is invoked immediately before mounting occurs. It is called before `render()`, therefore setting state in this method will not trigger a re-render. Avoid introducing any side-effects or subscriptions in this method. We need to make sure async calls for component initialization happened in `componentDidMount()` instead of `componentWillMount()`. @@ -1922,7 +1923,7 @@ **[⬆ Back to Top](#table-of-contents)** -66. ### What will happen if you use props in initial state? +67. ### What will happen if you use props in initial state? If the props on the component are changed without the component being refreshed, the new prop value will never be displayed because the constructor function will never update the current state of the component. The initialization of state from props only runs when the component is first created. @@ -1965,7 +1966,7 @@ **[⬆ Back to Top](#table-of-contents)** -67. ### How do you conditionally render components? +68. ### How do you conditionally render components? In some cases you want to render different components depending on some state. JSX does not render `false` or `undefined`, so you can use conditional _short-circuiting_ to render a given part of your component only if a certain condition is true. @@ -1991,7 +1992,7 @@ **[⬆ Back to Top](#table-of-contents)** -68. ### Why we need to be careful when spreading props on DOM elements? +69. ### Why we need to be careful when spreading props on DOM elements? When we _spread props_ we run into the risk of adding unknown HTML attributes, which is a bad practice. Instead we can use prop destructuring with `...rest` operator, so it will add only required props. @@ -2009,7 +2010,7 @@ **[⬆ Back to Top](#table-of-contents)** -69. ### How you use decorators in React? +70. ### How you use decorators in React? You can _decorate_ your _class_ components, which is the same as passing the component into a function. **Decorators** are flexible and readable way of modifying component functionality. @@ -2041,7 +2042,7 @@ **[⬆ Back to Top](#table-of-contents)** -70. ### How do you memoize a component? +71. ### How do you memoize a component? There are memoize libraries available which can be used on function components. @@ -2073,7 +2074,7 @@ **[⬆ Back to Top](#table-of-contents)** -71. ### How you implement Server Side Rendering or SSR? +72. ### How you implement Server Side Rendering or SSR? React is already equipped to handle rendering on Node servers. A special version of the DOM renderer is available, which follows the same pattern as on the client side. @@ -2088,13 +2089,13 @@ **[⬆ Back to Top](#table-of-contents)** -72. ### How to enable production mode in React? +73. ### How to enable production mode in React? You should use Webpack's `DefinePlugin` method to set `NODE_ENV` to `production`, by which it strip out things like propType validation and extra warnings. Apart from this, if you minify the code, for example, Uglify's dead-code elimination to strip out development only code and comments, it will drastically reduce the size of your bundle. **[⬆ Back to Top](#table-of-contents)** -73. ### What is CRA and its benefits? +74. ### What is CRA and its benefits? The `create-react-app` CLI tool allows you to quickly create & run React applications with no configuration step. @@ -2125,7 +2126,7 @@ **[⬆ Back to Top](#table-of-contents)** -74. ### What is the lifecycle methods order in mounting? +75. ### What is the lifecycle methods order in mounting? The lifecycle methods are called in the following order when an instance of a component is being created and inserted into the DOM. @@ -2136,7 +2137,7 @@ **[⬆ Back to Top](#table-of-contents)** -75. ### What are the lifecycle methods going to be deprecated in React v16? +76. ### What are the lifecycle methods going to be deprecated in React v16? The following lifecycle methods going to be unsafe coding practices and will be more problematic with async rendering. @@ -2148,7 +2149,7 @@ **[⬆ Back to Top](#table-of-contents)** -76. ### What is the purpose of `getDerivedStateFromProps()` lifecycle method? +77. ### What is the purpose of `getDerivedStateFromProps()` lifecycle method? The new static `getDerivedStateFromProps()` lifecycle method is invoked after a component is instantiated as well as before it is re-rendered. It can return an object to update state, or `null` to indicate that the new props do not require any state updates. @@ -2164,7 +2165,7 @@ **[⬆ Back to Top](#table-of-contents)** -77. ### What is the purpose of `getSnapshotBeforeUpdate()` lifecycle method? +78. ### What is the purpose of `getSnapshotBeforeUpdate()` lifecycle method? The new `getSnapshotBeforeUpdate()` lifecycle method is called right before DOM updates. The return value from this method will be passed as the third parameter to `componentDidUpdate()`. @@ -2180,13 +2181,13 @@ **[⬆ Back to Top](#table-of-contents)** -78. ### Do Hooks replace render props and higher order components? +79. ### Do Hooks replace render props and higher order components? Both render props and higher-order components render only a single child but in most of the cases Hooks are a simpler way to serve this by reducing nesting in your tree. **[⬆ Back to Top](#table-of-contents)** -79. ### What is the recommended way for naming components? +80. ### What is the recommended way for naming components? It is recommended to name the component by reference instead of using `displayName`. @@ -2218,7 +2219,7 @@ **[⬆ Back to Top](#table-of-contents)** -80. ### What is the recommended ordering of methods in component class? +81. ### What is the recommended ordering of methods in component class? _Recommended_ ordering of methods from _mounting_ to _render stage_: @@ -2239,7 +2240,7 @@ **[⬆ Back to Top](#table-of-contents)** -81. ### What is a switching component? +82. ### What is a switching component? A _switching component_ is a component that renders one of many components. We need to use object to map prop values to components. @@ -2272,7 +2273,7 @@ **[⬆ Back to Top](#table-of-contents)** -82. ### Why we need to pass a function to setState()? +83. ### Why we need to pass a function to setState()? The reason behind for this is that `setState()` is an asynchronous operation. React batches state changes for performance reasons, so the state may not change immediately after `setState()` is called. That means you should not rely on the current state when calling `setState()` since you can't be sure what that state will be. The solution is to pass a function to `setState()`, with the previous state as an argument. By doing this you can avoid issues with the user getting the old state value on access due to the asynchronous nature of `setState()`. From f84dcf62a29a86ba5d78afd4e076440715d842a9 Mon Sep 17 00:00:00 2001 From: Rutuja Sanjay Jotrao <95583405+RutujaJotrao@users.noreply.github.com> Date: Wed, 31 Jan 2024 12:51:05 +0530 Subject: [PATCH 061/149] Update README.md --- README.md | 163 +++++++++++++++++++++++++++--------------------------- 1 file changed, 82 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index 98b6f8e9..e02d7d8c 100644 --- a/README.md +++ b/README.md @@ -36,87 +36,88 @@ | --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | | **Core React** | | 1 | [What is React?](#what-is-react) | -| 2 | [What are the major features of React?](#what-are-the-major-features-of-react) | -| 3 | [What is JSX?](#what-is-jsx) | -| 4 | [What is the difference between Element and Component?](#what-is-the-difference-between-element-and-component) | -| 5 | [How to create components in React?](#how-to-create-components-in-react) | -| 6 | [When to use a Class Component over a Function Component?](#when-to-use-a-class-component-over-a-function-component) | -| 7 | [What are Pure Components?](#what-are-pure-components) | -| 8 | [What is state in React?](#what-is-state-in-react) | -| 9 | [What are props in React?](#what-are-props-in-react) | -| 10 | [What is the difference between state and props?](#what-is-the-difference-between-state-and-props) | -| 11 | [Why should we not update the state directly?](#why-should-we-not-update-the-state-directly) | -| 12 | [What is the purpose of callback function as an argument of setState()?](#what-is-the-purpose-of-callback-function-as-an-argument-of-setstate) | -| 13 | [What is the difference between HTML and React event handling?](#what-is-the-difference-between-html-and-react-event-handling) | -| 14 | [How to bind methods or event handlers in JSX callbacks?](#how-to-bind-methods-or-event-handlers-in-jsx-callbacks) | -| 15 | [How to pass a parameter to an event handler or callback?](#how-to-pass-a-parameter-to-an-event-handler-or-callback) | -| 16 | [What are synthetic events in React?](#what-are-synthetic-events-in-react) | -| 17 | [What are inline conditional expressions?](#what-are-inline-conditional-expressions) | -| 18 | [What is "key" prop and what is the benefit of using it in arrays of elements?](#what-is-key-prop-and-what-is-the-benefit-of-using-it-in-arrays-of-elements) | -| 19 | [What is the use of refs?](#what-is-the-use-of-refs) | -| 20 | [How to create refs?](#how-to-create-refs) | -| 21 | [What are forward refs?](#what-are-forward-refs) | -| 22 | [Which is preferred option with in callback refs and findDOMNode()?](#which-is-preferred-option-with-in-callback-refs-and-finddomnode) | -| 23 | [Why are String Refs legacy?](#why-are-string-refs-legacy) | -| 24 | [What is Virtual DOM?](#what-is-virtual-dom) | -| 25 | [How Virtual DOM works?](#how-virtual-dom-works) | -| 26 | [What is the difference between Shadow DOM and Virtual DOM?](#what-is-the-difference-between-shadow-dom-and-virtual-dom) | -| 27 | [What is React Fiber?](#what-is-react-fiber) | -| 28 | [What is the main goal of React Fiber?](#what-is-the-main-goal-of-react-fiber) | -| 29 | [What are controlled components?](#what-are-controlled-components) | -| 30 | [What are uncontrolled components?](#what-are-uncontrolled-components) | -| 31 | [What is the difference between createElement and cloneElement?](#what-is-the-difference-between-createelement-and-cloneelement) | -| 32 | [What is Lifting State Up in React?](#what-is-lifting-state-up-in-react) | -| 33 | [What are the different phases of component lifecycle?](#what-are-the-different-phases-of-component-lifecycle) | -| 34 | [What are the lifecycle methods of React?](#what-are-the-lifecycle-methods-of-react) | -| 35 | [What are Higher-Order components?](#what-are-higher-order-components) | -| 36 | [How to create props proxy for HOC component?](#how-to-create-props-proxy-for-hoc-component) | -| 37 | [What is context?](#what-is-context) | -| 38 | [What is children prop?](#what-is-children-prop) | -| 39 | [How to write comments in React?](#how-to-write-comments-in-react) | -| 40 | [What is the purpose of using super constructor with props argument?](#what-is-the-purpose-of-using-super-constructor-with-props-argument) | -| 41 | [What is reconciliation?](#what-is-reconciliation) | -| 42 | [How to set state with a dynamic key name?](#how-to-set-state-with-a-dynamic-key-name) | -| 43 | [What would be the common mistake of function being called every time the component renders?](#what-would-be-the-common-mistake-of-function-being-called-every-time-the-component-renders) | -| 44 | [Is lazy function supports named exports?](#is-lazy-function-supports-named-exports) | -| 45 | [Why React uses className over class attribute?](#why-react-uses-classname-over-class-attribute) | -| 46 | [What are fragments?](#what-are-fragments) | -| 47 | [Why fragments are better than container divs?](#why-fragments-are-better-than-container-divs) | -| 48 | [What are portals in React?](#what-are-portals-in-react) | -| 49 | [What are stateless components?](#what-are-stateless-components) | -| 50 | [What are stateful components?](#what-are-stateful-components) | -| 51 | [How to apply validation on props in React?](#how-to-apply-validation-on-props-in-react) | -| 52 | [What are the advantages of React?](#what-are-the-advantages-of-react) | -| 53 | [What are the limitations of React?](#what-are-the-limitations-of-react) | -| 54 | [What are error boundaries in React v16](#what-are-error-boundaries-in-react-v16) | -| 55 | [How are error boundaries handled in React v15?](#how-are-error-boundaries-handled-in-react-v15) | -| 56 | [What are the recommended ways for static type checking?](#what-are-the-recommended-ways-for-static-type-checking) | -| 57 | [What is the use of react-dom package?](#what-is-the-use-of-react-dom-package) | -| 58 | [What is the purpose of render method of react-dom?](#what-is-the-purpose-of-render-method-of-react-dom) | -| 59 | [What is ReactDOMServer?](#what-is-reactdomserver) | -| 60 | [How to use InnerHtml in React?](#how-to-use-innerhtml-in-react) | -| 61 | [How to use styles in React?](#how-to-use-styles-in-react) | -| 62 | [How events are different in React?](#how-events-are-different-in-react) | -| 63 | [What will happen if you use setState in constructor?](#what-will-happen-if-you-use-setstate-in-constructor) | -| 64 | [What is the impact of indexes as keys?](#what-is-the-impact-of-indexes-as-keys) | -| 65 | [Is it good to use setState() in componentWillMount() method?](#is-it-good-to-use-setstate-in-componentwillmount-method) | -| 66 | [What will happen if you use props in initial state?](#what-will-happen-if-you-use-props-in-initial-state) | -| 67 | [How do you conditionally render components?](#how-do-you-conditionally-render-components) | -| 68 | [Why we need to be careful when spreading props on DOM elements??](#why-we-need-to-be-careful-when-spreading-props-on-dom-elements) | -| 69 | [How you use decorators in React?](#how-you-use-decorators-in-react) | -| 70 | [How do you memoize a component?](#how-do-you-memoize-a-component) | -| 71 | [How you implement Server-Side Rendering or SSR?](#how-you-implement-server-side-rendering-or-ssr) | -| 72 | [How to enable production mode in React?](#how-to-enable-production-mode-in-react) | -| 73 | [What is CRA and its benefits?](#what-is-cra-and-its-benefits) | -| 74 | [What is the lifecycle methods order in mounting?](#what-is-the-lifecycle-methods-order-in-mounting) | -| 75 | [What are the lifecycle methods going to be deprecated in React v16?](#what-are-the-lifecycle-methods-going-to-be-deprecated-in-react-v16) | -| 76 | [What is the purpose of getDerivedStateFromProps() lifecycle method?](#what-is-the-purpose-of-getderivedstatefromprops-lifecycle-method) | -| 77 | [What is the purpose of getSnapshotBeforeUpdate() lifecycle method?](#what-is-the-purpose-of-getsnapshotbeforeupdate-lifecycle-method) | -| 78 | [Do Hooks replace render props and higher order components?](#do-hooks-replace-render-props-and-higher-order-components) | -| 79 | [What is the recommended way for naming components?](#what-is-the-recommended-way-for-naming-components) | -| 80 | [What is the recommended ordering of methods in component class?](#what-is-the-recommended-ordering-of-methods-in-component-class) | -| 81 | [What is a switching component?](#what-is-a-switching-component) | -| 82 | [Why we need to pass a function to setState()?](#why-we-need-to-pass-a-function-to-setstate) | +| 2 | [What is the history behind React evolution?](#What-is-the-history-behind-React-evolution) | +| 3 | [What are the major features of React?](#what-are-the-major-features-of-react) | +| 4 | [What is JSX?](#what-is-jsx) | +| 5 | [What is the difference between Element and Component?](#what-is-the-difference-between-element-and-component) | +| 6 | [How to create components in React?](#how-to-create-components-in-react) | +| 7 | [When to use a Class Component over a Function Component?](#when-to-use-a-class-component-over-a-function-component) | +| 8 | [What are Pure Components?](#what-are-pure-components) | +| 9 | [What is state in React?](#what-is-state-in-react) | +| 10 | [What are props in React?](#what-are-props-in-react) | +| 11 | [What is the difference between state and props?](#what-is-the-difference-between-state-and-props) | +| 12 | [Why should we not update the state directly?](#why-should-we-not-update-the-state-directly) | +| 13 | [What is the purpose of callback function as an argument of setState()?](#what-is-the-purpose-of-callback-function-as-an-argument-of-setstate) | +| 14 | [What is the difference between HTML and React event handling?](#what-is-the-difference-between-html-and-react-event-handling) | +| 15 | [How to bind methods or event handlers in JSX callbacks?](#how-to-bind-methods-or-event-handlers-in-jsx-callbacks) | +| 16 | [How to pass a parameter to an event handler or callback?](#how-to-pass-a-parameter-to-an-event-handler-or-callback) | +| 17 | [What are synthetic events in React?](#what-are-synthetic-events-in-react) | +| 18 | [What are inline conditional expressions?](#what-are-inline-conditional-expressions) | +| 19 | [What is "key" prop and what is the benefit of using it in arrays of elements?](#what-is-key-prop-and-what-is-the-benefit-of-using-it-in-arrays-of-elements) | +| 20 | [What is the use of refs?](#what-is-the-use-of-refs) | +| 21 | [How to create refs?](#how-to-create-refs) | +| 22 | [What are forward refs?](#what-are-forward-refs) | +| 23 | [Which is preferred option with in callback refs and findDOMNode()?](#which-is-preferred-option-with-in-callback-refs-and-finddomnode) | +| 24 | [Why are String Refs legacy?](#why-are-string-refs-legacy) | +| 25 | [What is Virtual DOM?](#what-is-virtual-dom) | +| 26 | [How Virtual DOM works?](#how-virtual-dom-works) | +| 27 | [What is the difference between Shadow DOM and Virtual DOM?](#what-is-the-difference-between-shadow-dom-and-virtual-dom) | +| 28 | [What is React Fiber?](#what-is-react-fiber) | +| 29 | [What is the main goal of React Fiber?](#what-is-the-main-goal-of-react-fiber) | +| 30 | [What are controlled components?](#what-are-controlled-components) | +| 31 | [What are uncontrolled components?](#what-are-uncontrolled-components) | +| 32 | [What is the difference between createElement and cloneElement?](#what-is-the-difference-between-createelement-and-cloneelement) | +| 33 | [What is Lifting State Up in React?](#what-is-lifting-state-up-in-react) | +| 34 | [What are the different phases of component lifecycle?](#what-are-the-different-phases-of-component-lifecycle) | +| 35 | [What are the lifecycle methods of React?](#what-are-the-lifecycle-methods-of-react) | +| 36 | [What are Higher-Order components?](#what-are-higher-order-components) | +| 37 | [How to create props proxy for HOC component?](#how-to-create-props-proxy-for-hoc-component) | +| 38 | [What is context?](#what-is-context) | +| 39 | [What is children prop?](#what-is-children-prop) | +| 40 | [How to write comments in React?](#how-to-write-comments-in-react) | +| 41 | [What is the purpose of using super constructor with props argument?](#what-is-the-purpose-of-using-super-constructor-with-props-argument) | +| 42 | [What is reconciliation?](#what-is-reconciliation) | +| 43 | [How to set state with a dynamic key name?](#how-to-set-state-with-a-dynamic-key-name) | +| 44 | [What would be the common mistake of function being called every time the component renders?](#what-would-be-the-common-mistake-of-function-being-called-every-time-the-component-renders) | +| 45 | [Is lazy function supports named exports?](#is-lazy-function-supports-named-exports) | +| 46 | [Why React uses className over class attribute?](#why-react-uses-classname-over-class-attribute) | +| 47 | [What are fragments?](#what-are-fragments) | +| 48 | [Why fragments are better than container divs?](#why-fragments-are-better-than-container-divs) | +| 49 | [What are portals in React?](#what-are-portals-in-react) | +| 50 | [What are stateless components?](#what-are-stateless-components) | +| 51 | [What are stateful components?](#what-are-stateful-components) | +| 52 | [How to apply validation on props in React?](#how-to-apply-validation-on-props-in-react) | +| 53 | [What are the advantages of React?](#what-are-the-advantages-of-react) | +| 54 | [What are the limitations of React?](#what-are-the-limitations-of-react) | +| 55 | [What are error boundaries in React v16](#what-are-error-boundaries-in-react-v16) | +| 56 | [How are error boundaries handled in React v15?](#how-are-error-boundaries-handled-in-react-v15) | +| 57 | [What are the recommended ways for static type checking?](#what-are-the-recommended-ways-for-static-type-checking) | +| 58 | [What is the use of react-dom package?](#what-is-the-use-of-react-dom-package) | +| 59 | [What is the purpose of render method of react-dom?](#what-is-the-purpose-of-render-method-of-react-dom) | +| 60 | [What is ReactDOMServer?](#what-is-reactdomserver) | +| 61 | [How to use InnerHtml in React?](#how-to-use-innerhtml-in-react) | +| 62 | [How to use styles in React?](#how-to-use-styles-in-react) | +| 63 | [How events are different in React?](#how-events-are-different-in-react) | +| 64 | [What will happen if you use setState in constructor?](#what-will-happen-if-you-use-setstate-in-constructor) | +| 65 | [What is the impact of indexes as keys?](#what-is-the-impact-of-indexes-as-keys) | +| 66 | [Is it good to use setState() in componentWillMount() method?](#is-it-good-to-use-setstate-in-componentwillmount-method) | +| 67 | [What will happen if you use props in initial state?](#what-will-happen-if-you-use-props-in-initial-state) | +| 68 | [How do you conditionally render components?](#how-do-you-conditionally-render-components) | +| 69 | [Why we need to be careful when spreading props on DOM elements??](#why-we-need-to-be-careful-when-spreading-props-on-dom-elements) | +| 70 | [How you use decorators in React?](#how-you-use-decorators-in-react) | +| 71 | [How do you memoize a component?](#how-do-you-memoize-a-component) | +| 72 | [How you implement Server-Side Rendering or SSR?](#how-you-implement-server-side-rendering-or-ssr) | +| 73 | [How to enable production mode in React?](#how-to-enable-production-mode-in-react) | +| 74 | [What is CRA and its benefits?](#what-is-cra-and-its-benefits) | +| 75 | [What is the lifecycle methods order in mounting?](#what-is-the-lifecycle-methods-order-in-mounting) | +| 76 | [What are the lifecycle methods going to be deprecated in React v16?](#what-are-the-lifecycle-methods-going-to-be-deprecated-in-react-v16) | +| 77 | [What is the purpose of getDerivedStateFromProps() lifecycle method?](#what-is-the-purpose-of-getderivedstatefromprops-lifecycle-method) | +| 78 | [What is the purpose of getSnapshotBeforeUpdate() lifecycle method?](#what-is-the-purpose-of-getsnapshotbeforeupdate-lifecycle-method) | +| 79 | [Do Hooks replace render props and higher order components?](#do-hooks-replace-render-props-and-higher-order-components) | +| 80 | [What is the recommended way for naming components?](#what-is-the-recommended-way-for-naming-components) | +| 81 | [What is the recommended ordering of methods in component class?](#what-is-the-recommended-ordering-of-methods-in-component-class) | +| 82 | [What is a switching component?](#what-is-a-switching-component) | +| 83 | [Why we need to pass a function to setState()?](#why-we-need-to-pass-a-function-to-setstate) | | 84 | [What are React Mixins?](#what-are-react-mixins) | | 85 | [Why is isMounted() an anti-pattern and what is the proper solution?](#why-is-ismounted-an-anti-pattern-and-what-is-the-proper-solution) | | 86 | [What are the Pointer Events supported in React?](#what-are-the-pointer-events-supported-in-react) | From ae7e8b7bacc54dd5490b741e9b99b0beb77e2208 Mon Sep 17 00:00:00 2001 From: PIYUSH NEGI <43876655+npiyush97@users.noreply.github.com> Date: Fri, 2 Feb 2024 17:14:15 +0530 Subject: [PATCH 062/149] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1805f7e3..c4956db8 100644 --- a/README.md +++ b/README.md @@ -1540,7 +1540,7 @@ } ``` - Ususally you don't need to use **** until unless there is a need of _key_ attribute. The usage of shorter syntax looks like below. + Usually, you don't need to use **** until unless there is a need of _key_ attribute. The usage of shorter syntax looks like below. ```jsx harmony function Story({title, description, date}) { From 7860daf6f85a5f74fd7b17fe2d4fb542e3b767ab Mon Sep 17 00:00:00 2001 From: athithyaramaa1 <149147655+athithyaramaa1@users.noreply.github.com> Date: Tue, 27 Feb 2024 15:36:26 +0530 Subject: [PATCH 063/149] Updated answer to when to use functional vs class components. made the answer concise and clear. --- README.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 78955890..40fbb1f3 100644 --- a/README.md +++ b/README.md @@ -543,6 +543,17 @@ 1. If you need a React functionality whose Function component equivalent is not present yet, like Error Boundaries. 2. In older versions, If the component needs _state or lifecycle methods_ then you need to use class component. + + So the summary to this question is as follows: + **Use Function Components:** + + - If you don't need state or lifecycle methods, and your component is purely presentational. + - For simplicity, readability, and modern code practices, especially with the use of React Hooks for state and side effects. + + **Use Class Components:** + + - If you need to manage state or use lifecycle methods. + - In scenarios where backward compatibility or integration with older code is necessary. **Note:** You can also use reusable [react error boundary](https://github.com/bvaughn/react-error-boundary) third-party component without writing any class. i.e, No need to use class components for Error boundaries. @@ -562,7 +573,7 @@ **[⬆ Back to Top](#table-of-contents)** -7. ### What are Pure Components? +8. ### What are Pure Components? Pure components are the components which render the same output for the same state and props. In function components, you can achieve these pure components through memoized `React.memo()` API wrapping around the component. This API prevents unnecessary re-renders by comparing the previous props and new props using shallow comparison. So it will be helpful for performance optimizations. @@ -610,7 +621,7 @@ **[⬆ Back to Top](#table-of-contents)** -8. ### What is state in React? +9. ### What is state in React? _State_ of a component is an object that holds some information that may change over the lifetime of the component. The important point is whenever the state object changes, the component re-renders. It is always recommended to make our state as simple as possible and minimize the number of stateful components. @@ -663,7 +674,7 @@ **[⬆ Back to Top](#table-of-contents)** -9. ### What are props in React? +10. ### What are props in React? _Props_ are inputs to components. They are single values or objects containing a set of values that are passed to components on creation similar to HTML-tag attributes. Here, the data is passed down from a parent component to a child component. From 97997b59a0dbdb069bbe5e87b20ee0290c2b6e9c Mon Sep 17 00:00:00 2001 From: Michele Gerarduzzi Date: Sun, 3 Mar 2024 17:33:54 +0100 Subject: [PATCH 064/149] fix(spacing): add missing space before parenthesis --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 78955890..22c2c596 100644 --- a/README.md +++ b/README.md @@ -383,7 +383,7 @@ 1. ### What is React? - React(aka React.js or ReactJS) is an **open-source front-end JavaScript library** that is used for building composable user interfaces, especially for single-page applications. It is used for handling view layer for web and mobile apps based on components in a declarative approach. + React (aka React.js or ReactJS) is an **open-source front-end JavaScript library** that is used for building composable user interfaces, especially for single-page applications. It is used for handling view layer for web and mobile apps based on components in a declarative approach. React was created by [Jordan Walke](https://github.com/jordwalke), a software engineer working for Facebook. React was first deployed on Facebook's News Feed in 2011 and on Instagram in 2012. From c35d03c1bd07f17de0c5a8f2d0281b3fe22f5c35 Mon Sep 17 00:00:00 2001 From: mehmet Date: Fri, 8 Mar 2024 23:43:17 +0100 Subject: [PATCH 065/149] feat: Update statement to reflect availability of React.lazy and Suspense for server-side rendering --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 22c2c596..f3135445 100644 --- a/README.md +++ b/README.md @@ -5954,9 +5954,7 @@ 274. ### What are loadable components? - If you want to do code-splitting in a server rendered app, it is recommend to use Loadable Components because React.lazy and Suspense is not yet available for server-side rendering. Loadable lets you render a dynamic import as a regular component. - - Lets take an example, + With the release of React 18, React.lazy and Suspense are now available for server-side rendering. However, prior to React 18, it was recommended to use Loadable Components for code-splitting in a server-side rendered app because React.lazy and Suspense were not available for server-side rendering. Loadable Components lets you render a dynamic import as a regular component. For example, you can use Loadable Components to load the OtherComponent in a separate bundle like this: ```javascript import loadable from "@loadable/component"; @@ -5973,6 +5971,9 @@ ``` Now OtherComponent will be loaded in a separated bundle + Loadable Components provides additional benefits beyond just code-splitting, such as automatic code reloading, error handling, and preloading. By using Loadable Components, you can ensure that your application loads quickly and efficiently, providing a better user experience for your users. + + **[⬆ Back to Top](#table-of-contents)** From b646bd6cccca6e6ee10a1c0e1b8e2f3bcbf79e79 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sat, 30 Mar 2024 22:40:15 +0800 Subject: [PATCH 066/149] Refactor existing questions and new questions about JSX --- README.md | 79 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 65 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 78955890..1abeb234 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ --- -**Note:** This repository is specific to ReactJS. Please check [Javascript Interview questions](https://github.com/sudheerj/javascript-interview-questions) for core javascript questions. +**Note:** This repository is specific to ReactJS. Please check [Javascript Interview questions](https://github.com/sudheerj/javascript-interview-questions) for core javascript questions and [DataStructures and Algorithms](https://github.com/sudheerj/datastructures-algorithms) for DSA related questions or problems. ### Table of Contents @@ -515,7 +515,7 @@ Components are the building blocks of creating User Interfaces(UI) in React. There are two possible ways to create a component. - 1. **Function Components:** This is the simplest way to create a component. Those are pure JavaScript functions that accept props object as the first parameter and return React elements to render the output: + 1. **Function Components:** This is the simplest way to create a component. Those are pure JavaScript functions that accept props object as the one and only one parameter and return React elements to render the output: ```jsx harmony function Greeting({ message }) { @@ -616,7 +616,7 @@ ![state](images/state.jpg) - Let's take an example of **User** component with message state. Here, **useState** hook has been used to add state to the User component and it returns an array with current state and function to update it. + Let's take an example of **User** component with `message` state. Here, **useState** hook has been used to add state to the User component and it returns an array with current state and function to update it. ```jsx harmony import React, { useState } from "react"; @@ -696,6 +696,7 @@

    {props.name}

    {props.age}

    +

    {props.gender}

    ); }; @@ -703,25 +704,27 @@ const ParentComponent = () => { return (
    - - + +
    ); }; ``` - The properties from props object can be accessed directly using destructing feature from ES6 (ECMAScript 2015). The above child component can be simplified like below. + The properties from props object can be accessed directly using destructing feature from ES6 (ECMAScript 2015). It is also possible to fallback to default value when the prop value is not specified. The above child component can be simplified like below. ```jsx harmony - const ChildComponent = ({name, age}) => { + const ChildComponent = ({name, age, gender="male"}) => { return (

    {name}

    {age}

    +

    {gender}

    ); }; ``` + **Note:** The default value won't be used if you pass `null` or `0` value. i.e, default value is only used if the prop value is missed or `undefined` value has been passed.
    See Class The Props accessed in Class Based Component as below @@ -736,6 +739,7 @@

    {this.props.name}

    {this.props.age}

    +

    {this.props.gender}

    ); } @@ -745,8 +749,8 @@ render() { return (
    - - + +
    ); } @@ -1339,12 +1343,32 @@ 38. ### What is children prop? - _Children_ is a prop (`this.props.children`) that allows you to pass components as data to other components, just like any other prop you use. Component tree put between component's opening and closing tag will be passed to that component as `children` prop. - - There are several methods available in the React API to work with this prop. These include `React.Children.map`, `React.Children.forEach`, `React.Children.count`, `React.Children.only`, `React.Children.toArray`. + _Children_ is a prop that allows you to pass components as data to other components, just like any other prop you use. Component tree put between component's opening and closing tag will be passed to that component as `children` prop. A simple usage of children prop looks as below, + ```jsx harmony + function MyDiv({ children }){ + return ( +
    + {children} +
    ; + ); + }; + + export default function Greeting() { + return ( + + {"Hello"} + {"World"} + + ); + } + ``` + +
    See Class +

    + ```jsx harmony const MyDiv = React.createClass({ render: function () { @@ -1360,6 +1384,10 @@ node ); ``` +

    +
    + + **Note:** There are several methods available in the legacy React API to work with this prop. These include `React.Children.map`, `React.Children.forEach`, `React.Children.count`, `React.Children.only`, `React.Children.toArray`. **[⬆ Back to Top](#table-of-contents)** @@ -1499,7 +1527,7 @@ 45. ### Why React uses `className` over `class` attribute? - The attribute `class` is a keyword in JavaScript, and JSX is an extension of JavaScript. That's the principle reason why React uses `className` instead of `class`. Pass a string as the `className` prop. + The attribute names written in JSX turned into keys of JavaScript objects and the JavaScript names cannot contain dashes or reversed words, it is recommended to use camelCase whereever applicable in JSX code. The attribute `class` is a keyword in JavaScript, and JSX is an extension of JavaScript. That's the principle reason why React uses `className` instead of `class`. Pass a string as the `className` prop. ```jsx harmony render() { @@ -7281,7 +7309,7 @@ const loadUser = async () => { **[⬆ Back to Top](#table-of-contents)** -336. ### Why does strict mode render twice in React? +338. ### Why does strict mode render twice in React? StrictMode renders components twice in development mode(not production) in order to detect any problems with your code and warn you about those problems. This is used to detect accidental side effects in the render phase. If you used `create-react-app` development tool then it automatically enables StrictMode by default. ```js @@ -7311,6 +7339,29 @@ const loadUser = async () => { **[⬆ Back to Top](#table-of-contents)** +339. ### What are the rules of JSX? + The below 3 rules needs to be followed while using JSX in a react application. + + 1. **Return a single root element**: + If you are returning multiple elements from a component, wrap them in a single parent element. Otherwise you will receive the below error in your browser console. + + ```html Adjacent JSX elements must be wrapped in an enclosing tag.``` + + 2. **All the tags needs to be closed:** + Unlike HTML, all tags needs to closed explicitly with in JSX. This rule applies for self-closing tags(like hr, br and img tags) as well. + 3. **Use camelCase naming:** + It is suggested to use camelCase naming for attributes in JSX. For example, the common attributes of HTML elements such as `class`, `tabindex` will be used as `className` and `tabIndex`. + **Note:** There is an exception for aria-* and data-* attributes which should be lower cased all the time. + +**[⬆ Back to Top](#table-of-contents)** + + 340. ### What is the reason behind multiple JSX tags to be wrapped? + + Behind the scenes, JSX is transformed into plain javascript objects. It is not possible to return two or more objects from a function without wrapping into an array. This is the reason you can't simply return two or more JSX tags from a function without + wrapping them into a single parent tag or a Fragement. + + **[⬆ Back to Top](#table-of-contents)** + ## Disclaimer The questions provided in this repository are the summary of frequently asked questions across numerous companies. We cannot guarantee that these questions will actually be asked during your interview process, nor should you focus on memorizing all of them. The primary purpose is for you to get a sense of what some companies might ask — do not get discouraged if you don't know the answer to all of them ⁠— that is ok! From 18826d29e99a6141bf9b89cca92a2aa8487f5705 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sun, 31 Mar 2024 19:49:43 +0800 Subject: [PATCH 067/149] Fix formatting issues --- README.md | 56 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index e19180f4..2449a156 100644 --- a/README.md +++ b/README.md @@ -978,6 +978,7 @@ 2. If you extract list item as separate component then apply _keys_ on list component instead of `li` tag. 3. There will be a warning message in the console if the `key` prop is not present on list items. 4. The key attribute accepts either string or number and internally convert it as string type. + 5. Don't generate the key on the fly something like `key={Math.random()}`. Because the keys will never match up between re-renders and DOM created everytime. **[⬆ Back to Top](#table-of-contents)** @@ -1354,7 +1355,7 @@ {children}
    ; ); - }; + } export default function Greeting() { return ( @@ -1916,7 +1917,7 @@ Keys should be stable, predictable, and unique so that React can keep track of elements. - In the below code snippet each element's key will be based on ordering, rather than tied to the data that is being represented. This limits the optimizations that React can do. + In the below code snippet each element's key will be based on ordering, rather than tied to the data that is being represented. This limits the optimizations that React can do and creates confusing bugs in the application. ```jsx harmony { @@ -1924,13 +1925,14 @@ } ``` - If you use element data for unique key, assuming todo.id is unique to this list and stable, React would be able to reorder elements without needing to reevaluate them as much. + If you use element data for unique key, assuming `todo.id` is unique to this list and stable, React would be able to reorder elements without needing to reevaluate them as much. ```jsx harmony { todos.map((todo) => ); } ``` + **Note:** If you don't specify `key` prop at all, React will use index as a key's value while iterating over an array of data. **[⬆ Back to Top](#table-of-contents)** @@ -7272,30 +7274,30 @@ const loadUser = async () => { 336. ### What is strict mode in React? - `React.StrictMode` is a useful component for highlighting potential problems in an application. Just like ``, `` does not render any extra DOM elements. It activates additional checks and warnings for its descendants. These checks apply for _development mode_ only. + `React.StrictMode` is a useful component for highlighting potential problems in an application. Just like ``, `` does not render any extra DOM elements. It activates additional checks and warnings for its descendants. These checks apply for _development mode_ only. - ```jsx harmony - import React from "react"; + ```jsx harmony + import React from "react"; - function ExampleApplication() { - return ( -
    -
    - -
    - - -
    -
    -
    -
    - ); - } - ``` + function ExampleApplication() { + return ( +
    +
    + +
    + + +
    +
    +
    +
    + ); + } + ``` - In the example above, the _strict mode_ checks apply to `` and `` components only. i.e., Part of the application only. + In the example above, the _strict mode_ checks apply to `` and `` components only. i.e., Part of the application only. - **[⬆ Back to Top](#table-of-contents)** + **[⬆ Back to Top](#table-of-contents)** 337. ### What is the benefit of strict mode? @@ -7341,16 +7343,16 @@ const loadUser = async () => { **[⬆ Back to Top](#table-of-contents)** 339. ### What are the rules of JSX? - The below 3 rules needs to be followed while using JSX in a react application. + The below 3 rules needs to be followed while using JSX in a react application. - 1. **Return a single root element**: + 1. **Return a single root element**: If you are returning multiple elements from a component, wrap them in a single parent element. Otherwise you will receive the below error in your browser console. ```html Adjacent JSX elements must be wrapped in an enclosing tag.``` - 2. **All the tags needs to be closed:** + 2. **All the tags needs to be closed:** Unlike HTML, all tags needs to closed explicitly with in JSX. This rule applies for self-closing tags(like hr, br and img tags) as well. - 3. **Use camelCase naming:** + 3. **Use camelCase naming:** It is suggested to use camelCase naming for attributes in JSX. For example, the common attributes of HTML elements such as `class`, `tabindex` will be used as `className` and `tabIndex`. **Note:** There is an exception for aria-* and data-* attributes which should be lower cased all the time. From 4676ac579825757548d1724f7e8dff86b9208ae1 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Tue, 2 Apr 2024 11:43:18 +0800 Subject: [PATCH 068/149] Add hooks and strict mode concepts --- README.md | 176 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 137 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 54c23ba7..07081ce7 100644 --- a/README.md +++ b/README.md @@ -376,8 +376,14 @@ | 333 | [What is a wrapper component ](#what-is-a-wrapper-component) | | 334 | [What are the differences between useEffect and useLayoutEffect hooks](#what-are-the-differences-between-useEffect-and-useLayoutEffect-hooks) | | 335 | [What are the differences between Functional and Class Components ](#what-are-the-differences-between-functional-and-class-components) | -| 336 | [What is strict mode in React?](#what-is-strict-mode-in-react) | -| 338 | [Why does strict mode render twice in React?](#why-does-strict-mode-render-twice-in-react) | +| 336 | [What is strict mode in React?](#what-is-strict-mode-in-react) +| 337 | [What is the benefit of strict mode?](#what-is-the-benefit-of-strict-mode) | +| 338 | [Why does strict mode render twice in React?](#why-does-strict-mode-render-twice-in-react)| +| 339 | [What are the rules of JSX?](#what-are-the-rules-of-JSX) | +| 340 | [What is the reason behind multiple JSX tags to be wrapped?](#what-is-the-reason-behind-multiple-JSX-tags-to-be-wrapped) | +| 341 | [How do you prevent mutating array variables?](#how-do-you-prevent-mutating-array-variables) | +| 342 | [What are capture phase events?](#what-are-capture-phase-events) | +| 343 | [How does React updates screen in an application?](#how-does-react-updates-screen-in-an-application) | ## Core React @@ -2423,15 +2429,15 @@ If you are rendering your component using JSX, the name of that component has to begin with a capital letter otherwise React will throw an error as an unrecognized tag. This convention is because only HTML elements and SVG tags can begin with a lowercase letter. ```jsx harmony - class SomeComponent extends Component { + function SomeComponent { // Code goes here } ``` - You can define component class which name starts with lowercase letter, but when it's imported it should have capital letter. Here lowercase is fine: + You can define function component which name starts with lowercase letter, but when it's imported it should have capital letter. Here lowercase is fine: ```jsx harmony - class myComponent extends Component { + function myComponent { render() { return
    ; } @@ -2878,6 +2884,21 @@ ```jsx harmony const data = { name: "John", age: 42 }; + function User { + return
    {JSON.stringify(data, null, 2)}
    ; + } + + const container = createRoot(document.getElementById("container")); + + container.render(); + ``` + +
    See Class +

    + + ```jsx harmony + const data = { name: "John", age: 42 }; + class User extends React.Component { render() { return

    {JSON.stringify(data, null, 2)}
    ; @@ -2887,6 +2908,9 @@ React.render(, document.getElementById("container")); ``` +

    +
    + **[⬆ Back to Top](#table-of-contents)** 106. ### Why you can't update props in React? @@ -5144,17 +5168,15 @@ You need to follow two rules in order to use hooks, - 1. **Call Hooks only at the top level of your react functions:** You shouldn’t call Hooks inside loops, conditions, or nested functions. This will ensure that Hooks are called in the same order each time a component renders and it preserves the state of Hooks between multiple useState and useEffect calls. - 2. **Call Hooks from React Functions only:** You shouldn’t call Hooks from regular JavaScript functions. Instead, you should call them from either function components or custom hooks. - - The eslint plugin named **eslint-plugin-react-hooks** can be used to enforce these two rules. + 1. **Call Hooks only at the top level of your react functions:** You should always use hooks at the top level of react function before any early returns. i.e, You shouldn’t call Hooks inside loops, conditions, or nested functions. This will ensure that Hooks are called in the same order each time a component renders and it preserves the state of Hooks between multiple re-renders due to useState and useEffect calls. + 2. **Call Hooks from React Functions only:** You shouldn’t call Hooks from regular JavaScript functions or class components. Instead, you should call them from either function components or custom hooks. **[⬆ Back to Top](#table-of-contents)** 228. ### How to ensure hooks followed the rules in your project? - React team released an ESLint plugin called **eslint-plugin-react-hooks** that enforces these two rules. You can add this plugin to your project using the below command, + React team released an ESLint plugin called **eslint-plugin-react-hooks** that enforces Hook's two rules. It is part of Hooks API. You can add this plugin to your project using the below command, ```javascript - npm install eslint-plugin-react-hooks@next + npm install eslint-plugin-react-hooks --save-dev ``` And apply the below config in your ESLint config file, ```javascript @@ -5170,7 +5192,7 @@ } } ``` - + The recommended `eslint-config-react-app` preset already includes the hooks rules of this plugin. For example, the linter enforce proper naming convention for hooks. If you rename your custom hooks which as prefix "use" to something else then linter won't allow you to call built-in hooks such as useState, useEffect etc inside of your custom hook anymore. **Note:** This plugin is intended to use in Create React App by default. @@ -5694,11 +5716,33 @@ 258. ### How do you pass an event handler to a component? - You can pass event handlers and other functions as props to child components. It can be used in child component as below, + You can pass event handlers and other functions as props to child components. The functions can be passed to child component as below, + + ```jsx + function Button({ onClick }) { + return ( + + ); + } + + export default function downloadExcel() { + function handleClick() { + alert('Downloaded'); + } + + return ; + } + ``` +
    See Class +

    ```html - + ``` +

    +
    **[⬆ Back to Top](#table-of-contents)** @@ -7289,38 +7333,41 @@ const loadUser = async () => { `React.StrictMode` is a useful component for highlighting potential problems in an application. Just like ``, `` does not render any extra DOM elements. It activates additional checks and warnings for its descendants. These checks apply for _development mode_ only. ```jsx harmony - import React from "react"; + import { StrictMode } from "react"; - function ExampleApplication() { + function App() { return (
    - +
    -
    +
    ); } ``` - In the example above, the _strict mode_ checks apply to `` and `` components only. i.e., Part of the application only. + In the example above, the _strict mode_ checks apply to `` and `` components only. i.e., Part of the application only. + + **Note:** Frameworks such as NextJS has this flag enabled by default. **[⬆ Back to Top](#table-of-contents)** 337. ### What is the benefit of strict mode? The will be helpful in the below cases, - 1. Whenever the component - 1. Identifying components with **unsafe lifecycle methods**. - 2. Warning about **legacy string ref** API usage. - 3. Detecting unexpected **side effects**. - 4. Detecting **legacy context** API. - 5. Warning about deprecated findDOMNode usage + 1. To find the bugs caused by impure rendering where the components will re-render twice. + 2. To find the bugs caused by missing cleanup of effects where the components will re-run effects one more extra time. + 3. Identifying components with **unsafe lifecycle methods**. + 4. Warning about **legacy string ref** API usage. + 5. Detecting unexpected **side effects**. + 6. Detecting **legacy context** API. + 7. Warning about deprecated **findDOMNode** usage **[⬆ Back to Top](#table-of-contents)** @@ -7328,29 +7375,31 @@ const loadUser = async () => { StrictMode renders components twice in development mode(not production) in order to detect any problems with your code and warn you about those problems. This is used to detect accidental side effects in the render phase. If you used `create-react-app` development tool then it automatically enables StrictMode by default. ```js - ReactDOM.render( - - {App} - , - document.getElementById('root') + const root = createRoot(document.getElementById('root')); + root.render( + + + ); ``` - If you want to disable this behavior then you can remove `strict` mode. + If you want to disable this behavior then you can simply remove `strict` mode. + ```js - ReactDOM.render( - {App}, - document.getElementById('root') + const root = createRoot(document.getElementById('root')); + root.render( + ); ``` To detect side effects the following functions are invoked twice: - 1. Class component constructor, render, and shouldComponentUpdate methods - 2. Class component static getDerivedStateFromProps method - 3. Function component bodies - 4. State updater functions - 5. Functions passed to useState, useMemo, or useReducer (any Hook) + 1. Function component bodies, excluding the code inside event handlers. + 2. Functions passed to `useState`, `useMemo`, or `useReducer` (any other Hook) + 3. Class component's `constructor`, `render`, and `shouldComponentUpdate` methods + 4. Class component static `getDerivedStateFromProps` method + 5. State updater functions + **[⬆ Back to Top](#table-of-contents)** @@ -7375,6 +7424,55 @@ const loadUser = async () => { Behind the scenes, JSX is transformed into plain javascript objects. It is not possible to return two or more objects from a function without wrapping into an array. This is the reason you can't simply return two or more JSX tags from a function without wrapping them into a single parent tag or a Fragement. + **[⬆ Back to Top](#table-of-contents)** + + 341. ### How do you prevent mutating array variables? + The preexisting variables outside of the function scope including state, props and context leads to a mutation and they result in unpredictable bugs during the rendering stage. The below points should be taken care while working with arrays variables. + + 1. You need to take copy of the original array and perform array operations on it for the rendering purpose. This is called local mutation. + 2. Avoid triggering mutation methods such as push, pop, sort and reverse methods on original array. It is safe to use filter, map and slice method because they create a new array. + + **[⬆ Back to Top](#table-of-contents)** + + 342. ### What are capture phase events? + The `onClickCapture` React event is helpful to catch all the events of child elements irrespective of event propagation logic or even if the events propagation stopped. This is useful if you need to log every click events for analytics purpose. + + For example, the below code triggers the click event of parent first followed by second level child eventhough leaf child button elements stops the propagation. + + ```jsx +
    alert('parent')}> +
    alert('child')}> +
    +
    + ``` + The event propagation for the above code snippet happens in the following order: + 1. It travels downwards in the DOM tree by calling all `onClickCapture` event handlers. + 2. It executes `onClick` event handler on the target element. + 3. It travels upwards in the DOM tree by call all `onClick` event handlers above to it. + + 343. ### How does React updates screen in an application? + + React updates UI in three steps, + 1. **Triggering or initiating a render:** The component is going to triggered for render in two ways. + + 1. **Initial render:** When the app starts, you can trigger the initial render by calling `creatRoot` with the target DOM node followed by invoking component's `render` method. For example, the following code snippet renders `App` component on root DOM node. + + ```jsx + import { createRoot } from 'react-dom/client'; + + const root = createRoot(document.getElementById('root')) + root.render(); + ``` + + 2. **Re-render when the state updated:** When you update the component state using the state setter function, the componen't state automatically queues for a render. + + 2. **Rendering components:** After triggering a render, React will call your components to display them on the screen. React will call the root component for initial render and call the function component whose state update triggered the render. This is a recursive process for all nested components of the target component. + + 3. **Commit changes to DOM:** After calling components, React will modify the DOM for initial render using `appendChild()` DOM API and apply minimal necessary DOM updates for re-renders based on differences between rerenders. + + **[⬆ Back to Top](#table-of-contents)** ## Disclaimer From 608d6bf3614382a4e132380ab1fed9480bac625e Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Tue, 2 Apr 2024 15:57:14 +0800 Subject: [PATCH 069/149] Add TOC toggle, update state and props questions --- README.md | 96 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 04c39519..350460d1 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,11 @@ ### Table of Contents +
    + +Hide/Show table of contents + + | No. | Questions | | --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | | **Core React** | @@ -385,6 +390,8 @@ | 342 | [What are capture phase events?](#what-are-capture-phase-events) | | 343 | [How does React updates screen in an application?](#how-does-react-updates-screen-in-an-application) | +
    + ## Core React 1. ### What is React? @@ -636,7 +643,7 @@ Let's take an example of **User** component with `message` state. Here, **useState** hook has been used to add state to the User component and it returns an array with current state and function to update it. ```jsx harmony - import React, { useState } from "react"; + import { useState } from "react"; function User() { const [message, setMessage] = useState("Welcome to React world"); @@ -649,6 +656,8 @@ } ``` + Whenever React calls your component or access `useState` hook, it gives you a snapshot of the state for that particular render. +
    See Class

    @@ -682,51 +691,51 @@ 10. ### What are props in React? - _Props_ are inputs to components. They are single values or objects containing a set of values that are passed to components on creation similar to HTML-tag attributes. Here, the data is passed down from a parent component to a child component. + _Props_ are inputs to components. They are single values or objects containing a set of values that are passed to components on creation similar to HTML-tag attributes. Here, the data is passed down from a parent component to a child component. - The primary purpose of props in React is to provide following component functionality: + The primary purpose of props in React is to provide following component functionality: - 1. Pass custom data to your component. - 2. Trigger state changes. - 3. Use via `this.props.reactProp` inside component's `render()` method. + 1. Pass custom data to your component. + 2. Trigger state changes. + 3. Use via `this.props.reactProp` inside component's `render()` method. - For example, let us create an element with `reactProp` property: + For example, let us create an element with `reactProp` property: - ```jsx harmony - - ``` + ```jsx harmony + + ``` - This `reactProp` (or whatever you came up with) attribute name then becomes a property attached to React's native props object which originally already exists on all components created using React library. + This `reactProp` (or whatever you came up with) attribute name then becomes a property attached to React's native props object which originally already exists on all components created using React library. - ```jsx harmony - props.reactProp - ``` + ```jsx harmony + props.reactProp + ``` - For example, the usage of props in function component looks like below: + For example, the usage of props in function component looks like below: - ```jsx - import React from "react"; - import ReactDOM from "react-dom"; + ```jsx + import React from "react"; + import ReactDOM from "react-dom"; - const ChildComponent = (props) => { - return ( -

    -

    {props.name}

    -

    {props.age}

    -

    {props.gender}

    -
    - ); - }; + const ChildComponent = (props) => { + return ( +
    +

    {props.name}

    +

    {props.age}

    +

    {props.gender}

    +
    + ); + }; - const ParentComponent = () => { - return ( -
    - - -
    - ); - }; - ``` + const ParentComponent = () => { + return ( +
    + + +
    + ); + }; + ``` The properties from props object can be accessed directly using destructing feature from ES6 (ECMAScript 2015). It is also possible to fallback to default value when the prop value is not specified. The above child component can be simplified like below. @@ -780,8 +789,10 @@ 10. ### What is the difference between state and props? In React, both `state` and `props` are plain JavaScript objects and used to manage the data of a component, but they are used in different ways and have different characteristics. - `state` is managed by the component itself and can be updated using the `setState()` function. Unlike props, state can be modified by the component and is used to manage the internal state of the component. Changes in the state trigger a re-render of the component and its children. - `props` (short for "properties") are passed to a component by its parent component and are `read-only`, meaning that they cannot be modified by the component itself. props can be used to configure the behavior of a component and to pass data between components. + + The `state` entity is managed by the component itself and can be updated using the setter(`setState()` for class components) function. Unlike props, state can be modified by the component and is used to manage the internal state of the component. Moreover, changes in the state trigger a re-render of the component and its children. The components cannot become reusable with the usage of state alone. + + On the otherhand, `props` (short for "properties") are passed to a component by its parent component and are `read-only`, meaning that they cannot be modified by the own component itself. Also, props can be used to configure the behavior of a component and to pass data between components. The components become reusable with the usage of props. **[⬆ Back to Top](#table-of-contents)** @@ -2915,7 +2926,7 @@ 106. ### Why you can't update props in React? - The React philosophy is that props should be _immutable_ and _top-down_. This means that a parent can send any prop values to a child, but the child can't modify received props. + The React philosophy is that props should be _immutable_(read only) and _top-down_. This means that a parent can send any prop values to a child, but the child can't modify received props. **[⬆ Back to Top](#table-of-contents)** @@ -7483,10 +7494,15 @@ const loadUser = async () => { 2. **Rendering components:** After triggering a render, React will call your components to display them on the screen. React will call the root component for initial render and call the function component whose state update triggered the render. This is a recursive process for all nested components of the target component. 3. **Commit changes to DOM:** After calling components, React will modify the DOM for initial render using `appendChild()` DOM API and apply minimal necessary DOM updates for re-renders based on differences between rerenders. - **[⬆ Back to Top](#table-of-contents)** + 344. ### How does React batch multiple state updates? + **[⬆ Back to Top](#table-of-contents)** + + 345. ### How does React batch multiple state updates? + **[⬆ Back to Top](#table-of-contents)** + ## Disclaimer The questions provided in this repository are the summary of frequently asked questions across numerous companies. We cannot guarantee that these questions will actually be asked during your interview process, nor should you focus on memorizing all of them. The primary purpose is for you to get a sense of what some companies might ask — do not get discouraged if you don't know the answer to all of them ⁠— that is ok! From b48a8c946efb494a7b19fb6768ffaacbad7182de Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Wed, 3 Apr 2024 00:03:35 +0800 Subject: [PATCH 070/149] Add state updates and hydration questions --- README.md | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 350460d1..8b6da034 100644 --- a/README.md +++ b/README.md @@ -389,6 +389,7 @@ Hide/Show table of contents | 341 | [How do you prevent mutating array variables?](#how-do-you-prevent-mutating-array-variables) | | 342 | [What are capture phase events?](#what-are-capture-phase-events) | | 343 | [How does React updates screen in an application?](#how-does-react-updates-screen-in-an-application) | +| 346 | [What is React hydration?](#what-is-react-hydration) |
    @@ -7498,9 +7499,105 @@ const loadUser = async () => { **[⬆ Back to Top](#table-of-contents)** 344. ### How does React batch multiple state updates? + React prevents component from re-rendering for each and every state update by grouping multiple state updates within an event handler. This strategy improves the application performance and this process known as **batching**. The older version of React only supported batching for browser events whereas React18 supported for asynchronous actions, timeouts and intervals along with native events. This improved version of batching is called **automatic batching**. + + Let's demonstrate this automatic batching feature with a below example. + + ```jsx + import { useState } from 'react'; + + export default function BatchingState() { + const [count, setCount] = useState(0); + const [message, setMessage] = useState('batching'); + + console.log('Application Rendered'); + + const handleUsers = () => { + fetch("https://jsonplaceholder.typicode.com/users/1").then(() => { + // Automatic Batching re-render only once + setCount(count +1); + setMessage('users fetched'); + }); + } + + return ( + <> +

    {count}

    + + + ) + } + ``` + + The preceeding code updated two state variables with in an event handler. However, React will perform automatic batching feature and the component will be re-rendered only once for better performance. + + **[⬆ Back to Top](#table-of-contents)** + + 345. ### Is it possible to prevent automatic batching? + Yes, it is possible to prevent automatic batching default behavior. There might be cases where you need to re-render your component after each state update or updating one state depends on another state variable. Considering this situation, React introduced `flushSync` method from `react-dom` API for the usecases where you need to flush state updates to DOM immediately. + + The usage of `flushSync` method within an `onClick` event handler will be looking like as below, + + ```jsx + import { flushSync } from 'react-dom'; + + const handleClick = () => { + flushSync(() => { + setClicked(!clicked); //Component will create a re-render here + }); + + setCount(count + 1); // Component will create a re-render again here + }; + ``` + In the above click handler, React will update DOM at first using flushSync and second time updates DOM because of the counter setter function by avoiding automatic batching. + **[⬆ Back to Top](#table-of-contents)** - 345. ### How does React batch multiple state updates? + 346. ### What is React hydration? + React hydration is used to add client-side JavaScript interactivity to pre-rendered static HTML generated by the server. It is used only for server-side rendering(SSR) to enhance the initial rendering time and make it SEO friendly application. This hydration acts as a bridge to reduce the gap between server side and client-side rendering. + + After the page loaded with generated static HTML, React will add application state and interactivity by attaching all event handlers for the respective elements. Let's demonstrate this with an example. + + Consider that React DOM API(using `renderToString`) generated HTML for `` component which contains ` + ); + } + + const html = renderToString(); + ``` + + The above code generates the below HTML with a header text and button component without any interactivity. + + ```html +

    Counter

    + + ``` + + At this stage `hydrateRoot` API can be used to perform hydration by attaching `onClick` event handler. + + ```jsx + import { hydrateRoot } from 'react-dom/client'; + import App from './App.js'; + + hydrateRoot(document.getElementById('root'), ); + ``` + After this step, you are able to run React application on server-side and hydrating the javascript bundle on client-side for smooth user experience and SEO purposes. + **[⬆ Back to Top](#table-of-contents)** ## Disclaimer From 51ddbbbce53f79567f6c2417d616c09c57a8b38a Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Wed, 3 Apr 2024 18:27:13 +0800 Subject: [PATCH 071/149] Add state update questions --- README.md | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 134 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b6da034..e9ecc98f 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Hide/Show table of contents | 42 | [What is reconciliation?](#what-is-reconciliation) | | 43 | [How to set state with a dynamic key name?](#how-to-set-state-with-a-dynamic-key-name) | | 44 | [What would be the common mistake of function being called every time the component renders?](#what-would-be-the-common-mistake-of-function-being-called-every-time-the-component-renders) | -| 45 | [Is lazy function supports named exports?](#is-lazy-function-supports-named-exports) | +| 45 | [Does the lazy function support named exports?](#does-the-lazy-function-support-named-exports) | | 46 | [Why React uses className over class attribute?](#why-react-uses-classname-over-class-attribute) | | 47 | [What are fragments?](#what-are-fragments) | | 48 | [Why fragments are better than container divs?](#why-fragments-are-better-than-container-divs) | @@ -390,6 +390,10 @@ Hide/Show table of contents | 342 | [What are capture phase events?](#what-are-capture-phase-events) | | 343 | [How does React updates screen in an application?](#how-does-react-updates-screen-in-an-application) | | 346 | [What is React hydration?](#what-is-react-hydration) | +| 347 | [What is React hydration?](#what-is-react-hydration) | +| 348 | [What is React hydration?](#what-is-react-hydration) | +| 349 | [What is React hydration?](#what-is-react-hydration) | +| 350 | [What are the preferred and non-preferred array operations for updating the state?](#what-are-the-preferred-and-non-preferred-array-operations-for-updating-the-state) | @@ -1528,7 +1532,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -44. ### Is lazy function supports named exports? +44. ### Does the lazy function support named exports? No, currently `React.lazy` function supports default exports only. If you would like to import modules which are named exports, you can create an intermediate module that reexports it as the default. It also ensures that tree shaking keeps working and don’t pull unused components. Let's take a component file which exports multiple named components, @@ -7600,6 +7604,134 @@ const loadUser = async () => { **[⬆ Back to Top](#table-of-contents)** + 347. ### How do you update objects inside state? + You cannot update the objects which exists in the state directly. Instead, you should create a fresh new object (or copy from the existing object) and update the latest state using the newly created object. Eventhough JavaScript objects are mutable, you need to treate objects inside state as read-only while updating the state. + + Let's see this comparison with an example. The issue with regular object mutation approach can be described by updating the user details fields of `Profile` component. The properties of `Profile` component such as firstName, lastName and age details mutated in an event handler as shown below. + + ```jsx + import { useState } from 'react'; + + export default function Profile() { + const [user, setUser] = useState({ + firstName: 'John', + lastName: 'Abraham', + age: 30 + }); + + function handleFirstNameChange(e) { + user.firstName = e.target.value; + } + + function handleLastNameChange(e) { + user.lastName = e.target.value; + } + + function handleAgeChange(e) { + user.age = e.target.value; + } + + return ( + <> + + + +

    + Profile: + {person.firstName}{' '} + {person.lastName}{' '} + ({person.age}) +

    + + ); + } + ``` + Once you run the application with above user profile component, you can observe that user profile details won't be update upon entering the input fields. + This issue can be fixed by creating a new copy of object which includes existing properties through spread syntax(...obj) and add changed values in a single event handler itself as shown below. + + ```jsx + handleProfileChange(e) { + setUser({ + ...user, + [e.target.name]: e.target.value + }); + } + ``` + + The above event handler is concise instead of maintaining separate event handler for each field. Now, UI displays the updated field values as expected without an issue. + + **[⬆ Back to Top](#table-of-contents)** + + 348. ### How do you update nested objects inside state? + You cannot simply use spread syntax for all kinds of objects inside state. Because spread syntax is shallow and it copies properties for one level deep only. If the object has nested object structure, UI doesn't work as expected with regular JavaScript nested property mutation. Let's demonstrate this behavior with an example of User object which has address nested object inside of it. + + ```jsx + const user = { + name: 'John', + age: 32, + address: { + country: 'Singapore', + postalCode: 440004 + } + } + ``` + + If you try to update the country nested field in a regular javascript fashion(as shown below) then user profile screen won't be updated with latest value. + + ```js + user.address.country = "Germany"; + ``` + This issue can be fixed by flattening all the fields into a top-level object or create a new object for each nested object and point it to it's parent object. In this example, first you need to create copy of address object and update it with the latest value. Later, the adress object should be linked to parent user object something like below. + + ```js + setUser({ + ...user, + address: { + ...user.address, + country: 'Germany' + } + }); + ``` + This approach is bit verbose but this workaround can be used for some levels of nested objects without any hassle. + + **[⬆ Back to Top](#table-of-contents)** + + 349. ### How do you update arrays inside state? + **[⬆ Back to Top](#table-of-contents)** + + 350. ### What are the preferred and non-preferred array operations for updating the state? + + The below table represent preferred and non-preferred array operations for updating the component state. + + | Action | Preferred | Non-preferred | + | ---------- | ------------------- | ----------------------- | + | Adding | concat, [...arr] | push, unshift | + | Removing | filter, slice | pop, shift, splice | + | Replacing | map | splice, arr[i] = someValue | + | sorting | copying to new array | reverse, sort | + + If you use Immer library then you can able to use all array methods without any problem. + +**[⬆ Back to Top](#table-of-contents)** + ## Disclaimer The questions provided in this repository are the summary of frequently asked questions across numerous companies. We cannot guarantee that these questions will actually be asked during your interview process, nor should you focus on memorizing all of them. The primary purpose is for you to get a sense of what some companies might ask — do not get discouraged if you don't know the answer to all of them ⁠— that is ok! From 73ee8ba8bf2e276f5273547ac8533d71b935f7ee Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Thu, 4 Apr 2024 19:04:45 +0800 Subject: [PATCH 072/149] Add immer for object updates --- README.md | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 73 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e9ecc98f..c4768871 100644 --- a/README.md +++ b/README.md @@ -389,11 +389,15 @@ Hide/Show table of contents | 341 | [How do you prevent mutating array variables?](#how-do-you-prevent-mutating-array-variables) | | 342 | [What are capture phase events?](#what-are-capture-phase-events) | | 343 | [How does React updates screen in an application?](#how-does-react-updates-screen-in-an-application) | +| 344 | [How does React batch multiple state updates?](#how-does-react-batch-multiple-state-updates) | +| 345 | [Is it possible to prevent automatic batching?](#is-it-possible-to-prevent-automatic-batching) | | 346 | [What is React hydration?](#what-is-react-hydration) | -| 347 | [What is React hydration?](#what-is-react-hydration) | -| 348 | [What is React hydration?](#what-is-react-hydration) | -| 349 | [What is React hydration?](#what-is-react-hydration) | -| 350 | [What are the preferred and non-preferred array operations for updating the state?](#what-are-the-preferred-and-non-preferred-array-operations-for-updating-the-state) | +| 347 | [How do you update objects inside state?](#how-do-you-update-objects-inside-state) | +| 348 | [How do you update nested objects inside state?](#How-do-you-update-nested-objects-inside-state) | +| 349 | [How do you update arrays inside state?](#how-do-you-update-arrays-inside-state) | +| 350 | [How do you use immer library for state updates?](#how-do-you-use-immer-library-for-state-updates) | +| 351 | [What are the benefits of preventing the direct state mutations?](#what-are-the-benefits-of-preventing-the-direct-state-mutations) | +| 352 | [What are the preferred and non-preferred array operations for updating the state?](#what-are-the-preferred-and-non-preferred-array-operations-for-updating-the-state) | @@ -7715,9 +7719,73 @@ const loadUser = async () => { **[⬆ Back to Top](#table-of-contents)** 349. ### How do you update arrays inside state? + Eventhough arrays in JavaScript are mutable in nature, you need to treat them as immutable while storing them in a state. That means, similar to objects, the arrays cannot be updated directly inside state. Instead, you need to create a copy of the existing array and then set the state to use newly copied array. + + To ensure that arrays are not mutated, the mutation operations like direct direct assigment(arr[1]='one'), push, pop, shift, unshift, splice etc methods should be avoided on original array. Instead, you can create a copy of existing array with help of array operations such as filter, map, slice, spread syntax etc. + + For example, the below push operation doesn't add the new todo to the total todo's list in an event handler. + + ```jsx + onClick = { + todos.push({ + id: id+1, + name: name + }) + } + ``` + This issue is fixed by replacing push operation with spread syntax where it will create a new array and the UI updated with new todo. + + ```jsx + onClick = { + [ + ...todos, + { id: id+1, name: name } + ] + } + ``` + + **[⬆ Back to Top](#table-of-contents)** + + 350. ### How do you use immer library for state updates? + Immer library enforces the immutability of state based on **copy-on-write** mechanism. It uses JavaScript proxy to keep track of updates to immutable states. Immer has 3 main states as below, + + 1. **Current state:** It refers to actual state + 2. **Draft state:** All new changes will be applied to this state. In this state, draft is just a proxy of the current state. + 3. **Next state:** It is formed after all mutations applied to the draft state + + Immer can be used by following below instructions, + + 1. Install the dependency using `npm install use-immer` command + 2. Replace `useState` hook with `useImmer` hook by importing at the top + 3. The setter function of `useImmer` hook can be used to update the state. + + For example, the mutation syntax of immer library simplies the nested address object of user state as follows, + + ```jsx + import { useImmer } from 'use-immer'; + const [user, setUser]= useImmer({ + name: 'John', + age: 32, + address: { + country: 'Singapore', + postalCode: 440004 + } + }); + + //Update user details upon any event + setUser(draft => { + draft.address.country = 'Germany'; + }); + ``` + The preceeding code enables you to update nested objects with a conceise mutation syntax. + + **[⬆ Back to Top](#table-of-contents)** + + 351. ### What are the benefits of preventing the direct state mutations? + **[⬆ Back to Top](#table-of-contents)** - 350. ### What are the preferred and non-preferred array operations for updating the state? + 352. ### What are the preferred and non-preferred array operations for updating the state? The below table represent preferred and non-preferred array operations for updating the component state. From ff6b0e0b722db1d150236521744e4226d3e670fa Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sat, 6 Apr 2024 23:54:26 +0800 Subject: [PATCH 073/149] Update controlled and uncontrolled components --- README.md | 70 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c4768871..3d63a7ce 100644 --- a/README.md +++ b/README.md @@ -1213,13 +1213,35 @@ Hide/Show table of contents 29. ### What are controlled components? - A component that controls the input elements within the forms on subsequent user input is called **Controlled Component**, i.e, every state mutation will have an associated handler function. + A component that controls the input elements within the forms on subsequent user input is called **Controlled Component**, i.e, every state mutation will have an associated handler function. That means, the displayed data is always in sync with the state of the component. - For example, to write all the names in uppercase letters, we use handleChange as below, + The controlled components will be implemented using the below steps, + + 1. Initialize the state using use state hooks in function components or inside constructor for class components. + 2. Set the value of the form element to the respective state variable. + 3. Create an event handler to handle the user input changes through useState updater function or setState from class component. + 4. Attach the above event handler to form elements change or click events + + For example, the name input field updates the user name using `handleChange` event handler as below, ```javascript - handleChange(event) { - this.setState({value: event.target.value.toUpperCase()}) + import React, { useState } from "react"; + + function UserProfile() { + const [username, setUsername] = useState(""); + + const handleChange = (e) => { + setUsername(e.target.value); + }; + + return ( +
    + +
    + ); } ``` @@ -1229,7 +1251,39 @@ Hide/Show table of contents The **Uncontrolled Components** are the ones that store their own state internally, and you query the DOM using a ref to find its current value when you need it. This is a bit more like traditional HTML. - In the below UserProfile component, the `name` input is accessed using ref. + The uncontrolled components will be implemented using the below steps, + 1. Create a ref using useRef react hook in function component or `React.createRef()` in function component. + 2. Attach this ref to the form element. + 3. The form element value can be accessed directly through `ref` in event handlers or `componentDidMount` for class components + + In the below UserProfile component, the `username` input is accessed using ref. + + ```jsx harmony + import React, { useRef } from "react"; + + function UserProfile() { + const usernameRef = useRef(null); + + const handleSubmit = (event) => { + event.preventDefault(); + console.log("The submitted username is: " + usernameRef.current.value); + }; + + return ( +
    + + +
    + ); + } + ``` + In most cases, it's recommend to use controlled components to implement forms. In a controlled component, form data is handled by a React component. The alternative is uncontrolled components, where form data is handled by the DOM itself. + +
    See Class +

    ```jsx harmony class UserProfile extends React.Component { @@ -1257,8 +1311,8 @@ Hide/Show table of contents } } ``` - - In most cases, it's recommend to use controlled components to implement forms. In a controlled component, form data is handled by a React component. The alternative is uncontrolled components, where form data is handled by the DOM itself. +

    +
    **[⬆ Back to Top](#table-of-contents)** @@ -7714,7 +7768,7 @@ const loadUser = async () => { } }); ``` - This approach is bit verbose but this workaround can be used for some levels of nested objects without any hassle. + This approach is bit verbose and not easy for deep hierarchical state updates. But this workaround can be used for few levels of nested objects without much hassle. **[⬆ Back to Top](#table-of-contents)** From 4900301211b5d9d757eff9be83599ebd31c3e246 Mon Sep 17 00:00:00 2001 From: Sudheer Jonna Date: Sat, 13 Apr 2024 15:05:30 +0800 Subject: [PATCH 074/149] Re-organized with new and old questions --- README.md | 9825 +++++++++++++++++++++++++++-------------------------- 1 file changed, 4961 insertions(+), 4864 deletions(-) diff --git a/README.md b/README.md index 3d63a7ce..370c5e71 100644 --- a/README.md +++ b/README.md @@ -51,354 +51,371 @@ Hide/Show table of contents | 9 | [What is state in React?](#what-is-state-in-react) | | 10 | [What are props in React?](#what-are-props-in-react) | | 11 | [What is the difference between state and props?](#what-is-the-difference-between-state-and-props) | -| 12 | [Why should we not update the state directly?](#why-should-we-not-update-the-state-directly) | -| 13 | [What is the purpose of callback function as an argument of setState()?](#what-is-the-purpose-of-callback-function-as-an-argument-of-setstate) | -| 14 | [What is the difference between HTML and React event handling?](#what-is-the-difference-between-html-and-react-event-handling) | -| 15 | [How to bind methods or event handlers in JSX callbacks?](#how-to-bind-methods-or-event-handlers-in-jsx-callbacks) | -| 16 | [How to pass a parameter to an event handler or callback?](#how-to-pass-a-parameter-to-an-event-handler-or-callback) | -| 17 | [What are synthetic events in React?](#what-are-synthetic-events-in-react) | -| 18 | [What are inline conditional expressions?](#what-are-inline-conditional-expressions) | -| 19 | [What is "key" prop and what is the benefit of using it in arrays of elements?](#what-is-key-prop-and-what-is-the-benefit-of-using-it-in-arrays-of-elements) | -| 20 | [What is the use of refs?](#what-is-the-use-of-refs) | -| 21 | [How to create refs?](#how-to-create-refs) | -| 22 | [What are forward refs?](#what-are-forward-refs) | -| 23 | [Which is preferred option with in callback refs and findDOMNode()?](#which-is-preferred-option-with-in-callback-refs-and-finddomnode) | -| 24 | [Why are String Refs legacy?](#why-are-string-refs-legacy) | -| 25 | [What is Virtual DOM?](#what-is-virtual-dom) | -| 26 | [How Virtual DOM works?](#how-virtual-dom-works) | -| 27 | [What is the difference between Shadow DOM and Virtual DOM?](#what-is-the-difference-between-shadow-dom-and-virtual-dom) | -| 28 | [What is React Fiber?](#what-is-react-fiber) | -| 29 | [What is the main goal of React Fiber?](#what-is-the-main-goal-of-react-fiber) | -| 30 | [What are controlled components?](#what-are-controlled-components) | -| 31 | [What are uncontrolled components?](#what-are-uncontrolled-components) | -| 32 | [What is the difference between createElement and cloneElement?](#what-is-the-difference-between-createelement-and-cloneelement) | -| 33 | [What is Lifting State Up in React?](#what-is-lifting-state-up-in-react) | -| 34 | [What are the different phases of component lifecycle?](#what-are-the-different-phases-of-component-lifecycle) | -| 35 | [What are the lifecycle methods of React?](#what-are-the-lifecycle-methods-of-react) | -| 36 | [What are Higher-Order components?](#what-are-higher-order-components) | -| 37 | [How to create props proxy for HOC component?](#how-to-create-props-proxy-for-hoc-component) | -| 38 | [What is context?](#what-is-context) | -| 39 | [What is children prop?](#what-is-children-prop) | -| 40 | [How to write comments in React?](#how-to-write-comments-in-react) | -| 41 | [What is the purpose of using super constructor with props argument?](#what-is-the-purpose-of-using-super-constructor-with-props-argument) | -| 42 | [What is reconciliation?](#what-is-reconciliation) | -| 43 | [How to set state with a dynamic key name?](#how-to-set-state-with-a-dynamic-key-name) | -| 44 | [What would be the common mistake of function being called every time the component renders?](#what-would-be-the-common-mistake-of-function-being-called-every-time-the-component-renders) | -| 45 | [Does the lazy function support named exports?](#does-the-lazy-function-support-named-exports) | -| 46 | [Why React uses className over class attribute?](#why-react-uses-classname-over-class-attribute) | -| 47 | [What are fragments?](#what-are-fragments) | -| 48 | [Why fragments are better than container divs?](#why-fragments-are-better-than-container-divs) | -| 49 | [What are portals in React?](#what-are-portals-in-react) | -| 50 | [What are stateless components?](#what-are-stateless-components) | -| 51 | [What are stateful components?](#what-are-stateful-components) | -| 52 | [How to apply validation on props in React?](#how-to-apply-validation-on-props-in-react) | -| 53 | [What are the advantages of React?](#what-are-the-advantages-of-react) | -| 54 | [What are the limitations of React?](#what-are-the-limitations-of-react) | -| 55 | [What are error boundaries in React v16](#what-are-error-boundaries-in-react-v16) | -| 56 | [How are error boundaries handled in React v15?](#how-are-error-boundaries-handled-in-react-v15) | -| 57 | [What are the recommended ways for static type checking?](#what-are-the-recommended-ways-for-static-type-checking) | -| 58 | [What is the use of react-dom package?](#what-is-the-use-of-react-dom-package) | -| 59 | [What is the purpose of render method of react-dom?](#what-is-the-purpose-of-render-method-of-react-dom) | -| 60 | [What is ReactDOMServer?](#what-is-reactdomserver) | -| 61 | [How to use InnerHtml in React?](#how-to-use-innerhtml-in-react) | -| 62 | [How to use styles in React?](#how-to-use-styles-in-react) | -| 63 | [How events are different in React?](#how-events-are-different-in-react) | -| 64 | [What will happen if you use setState in constructor?](#what-will-happen-if-you-use-setstate-in-constructor) | -| 65 | [What is the impact of indexes as keys?](#what-is-the-impact-of-indexes-as-keys) | -| 66 | [Is it good to use setState() in componentWillMount() method?](#is-it-good-to-use-setstate-in-componentwillmount-method) | -| 67 | [What will happen if you use props in initial state?](#what-will-happen-if-you-use-props-in-initial-state) | -| 68 | [How do you conditionally render components?](#how-do-you-conditionally-render-components) | -| 69 | [Why we need to be careful when spreading props on DOM elements??](#why-we-need-to-be-careful-when-spreading-props-on-dom-elements) | -| 70 | [How you use decorators in React?](#how-you-use-decorators-in-react) | -| 71 | [How do you memoize a component?](#how-do-you-memoize-a-component) | -| 72 | [How you implement Server-Side Rendering or SSR?](#how-you-implement-server-side-rendering-or-ssr) | -| 73 | [How to enable production mode in React?](#how-to-enable-production-mode-in-react) | -| 74 | [What is CRA and its benefits?](#what-is-cra-and-its-benefits) | -| 75 | [What is the lifecycle methods order in mounting?](#what-is-the-lifecycle-methods-order-in-mounting) | -| 76 | [What are the lifecycle methods going to be deprecated in React v16?](#what-are-the-lifecycle-methods-going-to-be-deprecated-in-react-v16) | -| 77 | [What is the purpose of getDerivedStateFromProps() lifecycle method?](#what-is-the-purpose-of-getderivedstatefromprops-lifecycle-method) | -| 78 | [What is the purpose of getSnapshotBeforeUpdate() lifecycle method?](#what-is-the-purpose-of-getsnapshotbeforeupdate-lifecycle-method) | -| 79 | [Do Hooks replace render props and higher order components?](#do-hooks-replace-render-props-and-higher-order-components) | -| 80 | [What is the recommended way for naming components?](#what-is-the-recommended-way-for-naming-components) | -| 81 | [What is the recommended ordering of methods in component class?](#what-is-the-recommended-ordering-of-methods-in-component-class) | -| 82 | [What is a switching component?](#what-is-a-switching-component) | -| 83 | [Why we need to pass a function to setState()?](#why-we-need-to-pass-a-function-to-setstate) | -| 84 | [What are React Mixins?](#what-are-react-mixins) | -| 85 | [Why is isMounted() an anti-pattern and what is the proper solution?](#why-is-ismounted-an-anti-pattern-and-what-is-the-proper-solution) | -| 86 | [What are the Pointer Events supported in React?](#what-are-the-pointer-events-supported-in-react) | -| 87 | [Why should component names start with capital letter?](#why-should-component-names-start-with-capital-letter) | -| 88 | [Are custom DOM attributes supported in React v16?](#are-custom-dom-attributes-supported-in-react-v16) | -| 89 | [What is the difference between constructor and getInitialState?](#what-is-the-difference-between-constructor-and-getinitialstate) | -| 90 | [Can you force a component to re-render without calling setState?](#can-you-force-a-component-to-re-render-without-calling-setstate) | -| 91 | [What is the difference between super() and super(props) in React using ES6 classes?](#what-is-the-difference-between-super-and-superprops-in-react-using-es6-classes) | -| 92 | [How to loop inside JSX?](#how-to-loop-inside-jsx) | -| 93 | [How do you access props in attribute quotes?](#how-do-you-access-props-in-attribute-quotes) | -| 94 | [What is React PropType array with shape?](#what-is-react-proptype-array-with-shape) | -| 95 | [How to conditionally apply class attributes?](#how-to-conditionally-apply-class-attributes) | -| 96 | [What is the difference between React and ReactDOM?](#what-is-the-difference-between-react-and-reactdom) | -| 97 | [Why ReactDOM is separated from React?](#why-reactdom-is-separated-from-react) | -| 98 | [How to use React label element?](#how-to-use-react-label-element) | -| 99 | [How to combine multiple inline style objects?](#how-to-combine-multiple-inline-style-objects) | -| 100 | [How to re-render the view when the browser is resized?](#how-to-re-render-the-view-when-the-browser-is-resized) | -| 101 | [What is the difference between setState and replaceState methods?](#what-is-the-difference-between-setstate-and-replacestate-methods) | -| 102 | [How to listen to state changes?](#how-to-listen-to-state-changes) | -| 103 | [What is the recommended approach of removing an array element in react state?](#what-is-the-recommended-approach-of-removing-an-array-element-in-react-state) | -| 104 | [Is it possible to use React without rendering HTML?](#is-it-possible-to-use-react-without-rendering-html) | -| 105 | [How to pretty print JSON with React?](#how-to-pretty-print-json-with-react) | -| 106 | [Why you can't update props in React?](#why-you-cant-update-props-in-react) | -| 107 | [How to focus an input element on page load?](#how-to-focus-an-input-element-on-page-load) | -| 108 | [What are the possible ways of updating objects in state?](#what-are-the-possible-ways-of-updating-objects-in-state) | -| 110 | [How can we find the version of React at runtime in the browser?](#how-can-we-find-the-version-of-react-at-runtime-in-the-browser) | -| 111 | [What are the approaches to include polyfills in your create-react-app?](#what-are-the-approaches-to-include-polyfills-in-your-create-react-app) | -| 112 | [How to use https instead of http in create-react-app?](#how-to-use-https-instead-of-http-in-create-react-app) | -| 113 | [How to avoid using relative path imports in create-react-app?](#how-to-avoid-using-relative-path-imports-in-create-react-app) | -| 114 | [How to add Google Analytics for react-router?](#how-to-add-google-analytics-for-react-router) | -| 115 | [How to update a component every second?](#how-to-update-a-component-every-second) | -| 116 | [How do you apply vendor prefixes to inline styles in React?](#how-do-you-apply-vendor-prefixes-to-inline-styles-in-react) | -| 117 | [How to import and export components using react and ES6?](#how-to-import-and-export-components-using-react-and-es6) | -| 118 | [What are the exceptions on React component naming?](#what-are-the-exceptions-on-react-component-naming) | -| 119 | [Why is a component constructor called only once?](#why-is-a-component-constructor-called-only-once) | -| 120 | [How to define constants in React?](#how-to-define-constants-in-react) | -| 121 | [How to programmatically trigger click event in React?](#how-to-programmatically-trigger-click-event-in-react) | -| 122 | [Is it possible to use async/await in plain React?](#is-it-possible-to-use-asyncawait-in-plain-react) | -| 123 | [What are the common folder structures for React?](#what-are-the-common-folder-structures-for-react) | -| 124 | [What are the popular packages for animation?](#what-are-the-popular-packages-for-animation) | -| 125 | [What is the benefit of styles modules?](#what-is-the-benefit-of-styles-modules) | -| 126 | [What are the popular React-specific linters?](#what-are-the-popular-react-specific-linters) | -| 127 | [How to make AJAX call and In which component lifecycle methods should I make an AJAX call?](#how-to-make-ajax-call-and-in-which-component-lifecycle-methods-should-i-make-an-ajax-call) | -| 128 | [What are render props?](#what-are-render-props) | +| 12 | [What is the difference between HTML and React event handling?](#what-is-the-difference-between-html-and-react-event-handling) | +| 13 | [What are synthetic events in React?](#what-are-synthetic-events-in-react) | +| 14 | [What are inline conditional expressions?](#what-are-inline-conditional-expressions) | +| 15 | [What is "key" prop and what is the benefit of using it in arrays of elements?](#what-is-key-prop-and-what-is-the-benefit-of-using-it-in-arrays-of-elements) | +| 16 | [What is Virtual DOM?](#what-is-virtual-dom) | +| 17 | [How Virtual DOM works?](#how-virtual-dom-works) | +| 18 | [What is the difference between Shadow DOM and Virtual DOM?](#what-is-the-difference-between-shadow-dom-and-virtual-dom) | +| 19 | [What is React Fiber?](#what-is-react-fiber) | +| 20 | [What is the main goal of React Fiber?](#what-is-the-main-goal-of-react-fiber) | +| 21 | [What are controlled components?](#what-are-controlled-components) | +| 22 | [What are uncontrolled components?](#what-are-uncontrolled-components) | +| 23 | [What is the difference between createElement and cloneElement?](#what-is-the-difference-between-createelement-and-cloneelement) | +| 24 | [What is Lifting State Up in React?](#what-is-lifting-state-up-in-react) | +| 25 | [What are Higher-Order components?](#what-are-higher-order-components) | +| 26 | [What is children prop?](#what-is-children-prop) | +| 27 | [How to write comments in React?](#how-to-write-comments-in-react) | +| 28 | [What is reconciliation?](#what-is-reconciliation) | +| 29 | [Does the lazy function support named exports?](#does-the-lazy-function-support-named-exports) | +| 30 | [Why React uses className over class attribute?](#why-react-uses-classname-over-class-attribute) | +| 31 | [What are fragments?](#what-are-fragments) | +| 32 | [Why fragments are better than container divs?](#why-fragments-are-better-than-container-divs) | +| 33 | [What are portals in React?](#what-are-portals-in-react) | +| 34 | [What are stateless components?](#what-are-stateless-components) | +| 35 | [What are stateful components?](#what-are-stateful-components) | +| 36 | [How to apply validation on props in React?](#how-to-apply-validation-on-props-in-react) | +| 37 | [What are the advantages of React?](#what-are-the-advantages-of-react) | +| 38 | [What are the limitations of React?](#what-are-the-limitations-of-react) | +| 39 | [What are the recommended ways for static type checking?](#what-are-the-recommended-ways-for-static-type-checking) | +| 40 | [What is the use of react-dom package?](#what-is-the-use-of-react-dom-package) | +| 41 | [What is ReactDOMServer?](#what-is-reactdomserver) | +| 42 | [How to use InnerHtml in React?](#how-to-use-innerhtml-in-react) | +| 43 | [How to use styles in React?](#how-to-use-styles-in-react) | +| 44 | [How events are different in React?](#how-events-are-different-in-react) | +| 45 | [What is the impact of indexes as keys?](#what-is-the-impact-of-indexes-as-keys) | +| 46 | [How do you conditionally render components?](#how-do-you-conditionally-render-components) | +| 47 | [Why we need to be careful when spreading props on DOM elements??](#why-we-need-to-be-careful-when-spreading-props-on-dom-elements) | +| 48 | [How do you memoize a component?](#how-do-you-memoize-a-component) | +| 49 | [How you implement Server-Side Rendering or SSR?](#how-you-implement-server-side-rendering-or-ssr) | +| 50 | [How to enable production mode in React?](#how-to-enable-production-mode-in-react) | +| 51 | [Do Hooks replace render props and higher order components?](#do-hooks-replace-render-props-and-higher-order-components) | +| 52 | [What is a switching component?](#what-is-a-switching-component) | +| 53 | [What are React Mixins?](#what-are-react-mixins) | +| 54 | [What are the Pointer Events supported in React?](#what-are-the-pointer-events-supported-in-react) | +| 55 | [Why should component names start with capital letter?](#why-should-component-names-start-with-capital-letter) | +| 56 | [Are custom DOM attributes supported in React v16?](#are-custom-dom-attributes-supported-in-react-v16) | +| 57 | [How to loop inside JSX?](#how-to-loop-inside-jsx) | +| 58 | [How do you access props in attribute quotes?](#how-do-you-access-props-in-attribute-quotes) | +| 59 | [What is React PropType array with shape?](#what-is-react-proptype-array-with-shape) | +| 60 | [How to conditionally apply class attributes?](#how-to-conditionally-apply-class-attributes) | +| 61 | [What is the difference between React and ReactDOM?](#what-is-the-difference-between-react-and-reactdom) | +| 62 | [Why ReactDOM is separated from React?](#why-reactdom-is-separated-from-react) | +| 63 | [How to use React label element?](#how-to-use-react-label-element) | +| 64 | [How to combine multiple inline style objects?](#how-to-combine-multiple-inline-style-objects) | +| 65 | [How to re-render the view when the browser is resized?](#how-to-re-render-the-view-when-the-browser-is-resized) | +| 66 | [How to pretty print JSON with React?](#how-to-pretty-print-json-with-react) | +| 67 | [Why you can't update props in React?](#why-you-cant-update-props-in-react) | +| 68 | [How to focus an input element on page load?](#how-to-focus-an-input-element-on-page-load) | +| 69 | [How can we find the version of React at runtime in the browser?](#how-can-we-find-the-version-of-react-at-runtime-in-the-browser) | +| 70 | [How to add Google Analytics for react-router?](#how-to-add-google-analytics-for-react-router) | +| 71 | [How do you apply vendor prefixes to inline styles in React?](#how-do-you-apply-vendor-prefixes-to-inline-styles-in-react) | +| 72 | [How to import and export components using react and ES6?](#how-to-import-and-export-components-using-react-and-es6) | +| 73 | [What are the exceptions on React component naming?](#what-are-the-exceptions-on-react-component-naming) | +| 74 | [Is it possible to use async/await in plain React?](#is-it-possible-to-use-asyncawait-in-plain-react) | +| 75 | [What are the common folder structures for React?](#what-are-the-common-folder-structures-for-react) | +| 76 | [What are the popular packages for animation?](#what-are-the-popular-packages-for-animation) | +| 77 | [What is the benefit of styles modules?](#what-is-the-benefit-of-styles-modules) | +| 78 | [What are the popular React-specific linters?](#what-are-the-popular-react-specific-linters) | | | **React Router** | -| 129 | [What is React Router?](#what-is-react-router) | -| 130 | [How React Router is different from history library?](#how-react-router-is-different-from-history-library) | -| 131 | [What are the \ components of React Router v4?](#what-are-the-router-components-of-react-router-v4) | -| 132 | [What is the purpose of push and replace methods of history?](#what-is-the-purpose-of-push-and-replace-methods-of-history) | -| 133 | [How do you programmatically navigate using React router v4?](#how-do-you-programmatically-navigate-using-react-router-v4) | -| 134 | [How to get query parameters in React Router v4](#how-to-get-query-parameters-in-react-router-v4) | -| 135 | [Why you get "Router may have only one child element" warning?](#why-you-get-router-may-have-only-one-child-element-warning) | -| 136 | [How to pass params to history.push method in React Router v4?](#how-to-pass-params-to-historypush-method-in-react-router-v4) | -| 137 | [How to implement default or NotFound page?](#how-to-implement-default-or-notfound-page) | -| 138 | [How to get history on React Router v4?](#how-to-get-history-on-react-router-v4) | -| 139 | [How to perform automatic redirect after login?](#how-to-perform-automatic-redirect-after-login) | +| 79 | [What is React Router?](#what-is-react-router) | +| 80 | [How React Router is different from history library?](#how-react-router-is-different-from-history-library) | +| 81 | [What are the \ components of React Router v4?](#what-are-the-router-components-of-react-router-v4) | +| 82 | [What is the purpose of push and replace methods of history?](#what-is-the-purpose-of-push-and-replace-methods-of-history) | +| 83 | [How do you programmatically navigate using React router v4?](#how-do-you-programmatically-navigate-using-react-router-v4) | +| 84 | [How to get query parameters in React Router v4](#how-to-get-query-parameters-in-react-router-v4) | +| 85 | [Why you get "Router may have only one child element" warning?](#why-you-get-router-may-have-only-one-child-element-warning) | +| 86 | [How to pass params to history.push method in React Router v4?](#how-to-pass-params-to-historypush-method-in-react-router-v4) | +| 87 | [How to implement default or NotFound page?](#how-to-implement-default-or-notfound-page) | +| 88 | [How to get history on React Router v4?](#how-to-get-history-on-react-router-v4) | +| 89 | [How to perform automatic redirect after login?](#how-to-perform-automatic-redirect-after-login) | | | **React Internationalization** | -| 140 | [What is React-Intl?](#what-is-react-intl) | -| 141 | [What are the main features of React Intl?](#what-are-the-main-features-of-react-intl) | -| 142 | [What are the two ways of formatting in React Intl?](#what-are-the-two-ways-of-formatting-in-react-intl) | -| 143 | [How to use FormattedMessage as placeholder using React Intl?](#how-to-use-formattedmessage-as-placeholder-using-react-intl) | -| 144 | [How to access current locale with React Intl](#how-to-access-current-locale-with-react-intl) | -| 145 | [How to format date using React Intl?](#how-to-format-date-using-react-intl) | +| 90 | [What is React Intl?](#what-is-react-intl) | +| 91 | [What are the main features of React Intl?](#what-are-the-main-features-of-react-intl) | +| 92 | [What are the two ways of formatting in React Intl?](#what-are-the-two-ways-of-formatting-in-react-intl) | +| 93 | [How to use FormattedMessage as placeholder using React Intl?](#how-to-use-formattedmessage-as-placeholder-using-react-intl) | +| 94 | [How to access current locale with React Intl](#how-to-access-current-locale-with-react-intl) | +| 95 | [How to format date using React Intl?](#how-to-format-date-using-react-intl) | | | **React Testing** | -| 146 | [What is Shallow Renderer in React testing?](#what-is-shallow-renderer-in-react-testing) | -| 147 | [What is TestRenderer package in React?](#what-is-testrenderer-package-in-react) | -| 148 | [What is the purpose of ReactTestUtils package?](#what-is-the-purpose-of-reacttestutils-package) | -| 149 | [What is Jest?](#what-is-jest) | -| 150 | [What are the advantages of Jest over Jasmine?](#what-are-the-advantages-of-jest-over-jasmine) | -| 151 | [Give a simple example of Jest test case](#give-a-simple-example-of-jest-test-case) | +| 96 | [What is Shallow Renderer in React testing?](#what-is-shallow-renderer-in-react-testing) | +| 97 | [What is TestRenderer package in React?](#what-is-testrenderer-package-in-react) | +| 98 | [What is the purpose of ReactTestUtils package?](#what-is-the-purpose-of-reacttestutils-package) | +| 99 | [What is Jest?](#what-is-jest) | +| 100 | [What are the advantages of Jest over Jasmine?](#what-are-the-advantages-of-jest-over-jasmine) | +| 101 | [Give a simple example of Jest test case](#give-a-simple-example-of-jest-test-case) | | | **React Redux** | -| 152 | [What is Flux?](#what-is-flux) | -| 153 | [What is Redux?](#what-is-redux) | -| 154 | [What are the core principles of Redux?](#what-are-the-core-principles-of-redux) | -| 155 | [What are the downsides of Redux compared to Flux?](#what-are-the-downsides-of-redux-compared-to-flux) | -| 156 | [What is the difference between mapStateToProps() and mapDispatchToProps()?](#what-is-the-difference-between-mapstatetoprops-and-mapdispatchtoprops) | -| 157 | [Can I dispatch an action in reducer?](#can-i-dispatch-an-action-in-reducer) | -| 158 | [How to access Redux store outside a component?](#how-to-access-redux-store-outside-a-component) | -| 159 | [What are the drawbacks of MVW pattern](#what-are-the-drawbacks-of-mvw-pattern) | -| 160 | [Are there any similarities between Redux and RxJS?](#are-there-any-similarities-between-redux-and-rxjs) | -| 161 | [How to dispatch an action on load?](#how-to-dispatch-an-action-on-load) | -| 162 | [How to use connect from React Redux?](#how-to-use-connect-from-react-redux) | -| 163 | [How to reset state in Redux?](#how-to-reset-state-in-redux) | -| 164 | [Whats the purpose of at symbol in the redux connect decorator?](#whats-the-purpose-of-at-symbol-in-the-redux-connect-decorator) | -| 165 | [What is the difference between React context and React Redux?](#what-is-the-difference-between-react-context-and-react-redux) | -| 166 | [Why are Redux state functions called reducers?](#why-are-redux-state-functions-called-reducers) | -| 167 | [How to make AJAX request in Redux?](#how-to-make-ajax-request-in-redux) | -| 168 | [Should I keep all component's state in Redux store?](#should-i-keep-all-components-state-in-redux-store) | -| 169 | [What is the proper way to access Redux store?](#what-is-the-proper-way-to-access-redux-store) | -| 170 | [What is the difference between component and container in React Redux?](#what-is-the-difference-between-component-and-container-in-react-redux) | -| 171 | [What is the purpose of the constants in Redux? ](#what-is-the-purpose-of-the-constants-in-redux) | -| 172 | [What are the different ways to write mapDispatchToProps()?](#what-are-the-different-ways-to-write-mapdispatchtoprops) | -| 173 | [What is the use of the ownProps parameter in mapStateToProps() and mapDispatchToProps()?](#what-is-the-use-of-the-ownprops-parameter-in-mapstatetoprops-and-mapdispatchtoprops) | -| 174 | [How to structure Redux top level directories?](#how-to-structure-redux-top-level-directories) | -| 175 | [What is redux-saga?](#what-is-redux-saga) | -| 176 | [What is the mental model of redux-saga?](#what-is-the-mental-model-of-redux-saga) | -| 177 | [What are the differences between call and put in redux-saga](#what-are-the-differences-between-call-and-put-in-redux-saga) | -| 178 | [What is Redux Thunk?](#what-is-redux-thunk) | -| 179 | [What are the differences between redux-saga and redux-thunk](#what-are-the-differences-between-redux-saga-and-redux-thunk) | -| 180 | [What is Redux DevTools?](#what-is-redux-devtools) | -| 181 | [What are the features of Redux DevTools?](#what-are-the-features-of-redux-devtools) | -| 182 | [What are Redux selectors and Why to use them?](#what-are-redux-selectors-and-why-to-use-them) | -| 183 | [What is Redux Form?](#what-is-redux-form) | -| 184 | [What are the main features of Redux Form?](#what-are-the-main-features-of-redux-form) | -| 185 | [How to add multiple middlewares to Redux?](#how-to-add-multiple-middlewares-to-redux) | -| 186 | [How to set initial state in Redux?](#how-to-set-initial-state-in-redux) | -| 187 | [How Relay is different from Redux?](#how-relay-is-different-from-redux) | -| 188 | [What is an action in Redux?](#what-is-an-action-in-redux) | +| 102 | [What is Flux?](#what-is-flux) | +| 103 | [What is Redux?](#what-is-redux) | +| 104 | [What are the core principles of Redux?](#what-are-the-core-principles-of-redux) | +| 105 | [What are the downsides of Redux compared to Flux?](#what-are-the-downsides-of-redux-compared-to-flux) | +| 106 | [What is the difference between mapStateToProps() and mapDispatchToProps()?](#what-is-the-difference-between-mapstatetoprops-and-mapdispatchtoprops) | +| 107 | [Can I dispatch an action in reducer?](#can-i-dispatch-an-action-in-reducer) | +| 108 | [How to access Redux store outside a component?](#how-to-access-redux-store-outside-a-component) | +| 109 | [What are the drawbacks of MVW pattern](#what-are-the-drawbacks-of-mvw-pattern) | +| 110 | [Are there any similarities between Redux and RxJS?](#are-there-any-similarities-between-redux-and-rxjs) | +| 111 | [How to reset state in Redux?](#how-to-reset-state-in-redux) | +| 112 | [What is the difference between React context and React Redux?](#what-is-the-difference-between-react-context-and-react-redux) | +| 113 | [Why are Redux state functions called reducers?](#why-are-redux-state-functions-called-reducers) | +| 114 | [How to make AJAX request in Redux?](#how-to-make-ajax-request-in-redux) | +| 115 | [Should I keep all component's state in Redux store?](#should-i-keep-all-components-state-in-redux-store) | +| 116 | [What is the proper way to access Redux store?](#what-is-the-proper-way-to-access-redux-store) | +| 117 | [What is the difference between component and container in React Redux?](#what-is-the-difference-between-component-and-container-in-react-redux) | +| 118 | [What is the purpose of the constants in Redux? ](#what-is-the-purpose-of-the-constants-in-redux) | +| 119 | [What are the different ways to write mapDispatchToProps()?](#what-are-the-different-ways-to-write-mapdispatchtoprops) | +| 120 | [What is the use of the ownProps parameter in mapStateToProps() and mapDispatchToProps()?](#what-is-the-use-of-the-ownprops-parameter-in-mapstatetoprops-and-mapdispatchtoprops) | +| 121 | [How to structure Redux top level directories?](#how-to-structure-redux-top-level-directories) | +| 122 | [What is redux-saga?](#what-is-redux-saga) | +| 123 | [What is the mental model of redux-saga?](#what-is-the-mental-model-of-redux-saga) | +| 124 | [What are the differences between call and put in redux-saga](#what-are-the-differences-between-call-and-put-in-redux-saga) | +| 125 | [What is Redux Thunk?](#what-is-redux-thunk) | +| 126 | [What are the differences between redux-saga and redux-thunk](#what-are-the-differences-between-redux-saga-and-redux-thunk) | +| 127 | [What is Redux DevTools?](#what-is-redux-devtools) | +| 128 | [What are the features of Redux DevTools?](#what-are-the-features-of-redux-devtools) | +| 129 | [What are Redux selectors and Why to use them?](#what-are-redux-selectors-and-why-to-use-them) | +| 130 | [What is Redux Form?](#what-is-redux-form) | +| 131 | [What are the main features of Redux Form?](#what-are-the-main-features-of-redux-form) | +| 132 | [How to add multiple middlewares to Redux?](#how-to-add-multiple-middlewares-to-redux) | +| 133 | [How to set initial state in Redux?](#how-to-set-initial-state-in-redux) | +| 134 | [How Relay is different from Redux?](#how-relay-is-different-from-redux) | +| 135 | [What is an action in Redux?](#what-is-an-action-in-redux) | | | **React Native** | -| 188 | [What is the difference between React Native and React?](#what-is-the-difference-between-react-native-and-react) | -| 189 | [How to test React Native apps?](#how-to-test-react-native-apps) | -| 190 | [How to do logging in React Native?](#how-to-do-logging-in-react-native) | -| 191 | [How to debug your React Native?](#how-to-debug-your-react-native) | +| 136 | [What is the difference between React Native and React?](#what-is-the-difference-between-react-native-and-react) | +| 137 | [How to test React Native apps?](#how-to-test-react-native-apps) | +| 138 | [How to do logging in React Native?](#how-to-do-logging-in-react-native) | +| 139 | [How to debug your React Native?](#how-to-debug-your-react-native) | | | **React supported libraries and Integration** | -| 192 | [What is reselect and how it works?](#what-is-reselect-and-how-it-works) | -| 193 | [What is Flow?](#what-is-flow) | -| 194 | [What is the difference between Flow and PropTypes?](#what-is-the-difference-between-flow-and-proptypes) | -| 195 | [How to use font-awesome icons in React?](#how-to-use-font-awesome-icons-in-react) | -| 196 | [What is React Dev Tools?](#what-is-react-dev-tools) | -| 197 | [Why is DevTools not loading in Chrome for local files?](#why-is-devtools-not-loading-in-chrome-for-local-files) | -| 198 | [How to use Polymer in React?](#how-to-use-polymer-in-react) | -| 199 | [What are the advantages of React over Vue.js?](#what-are-the-advantages-of-react-over-vuejs) | -| 200 | [What is the difference between React and Angular?](#what-is-the-difference-between-react-and-angular) | -| 201 | [Why React tab is not showing up in DevTools?](#why-react-tab-is-not-showing-up-in-devtools) | -| 202 | [What are styled components?](#what-are-styled-components) | -| 203 | [Give an example of Styled Components?](#give-an-example-of-styled-components) | -| 204 | [What is Relay?](#what-is-relay) | -| 205 | [How to use TypeScript in create-react-app application?](#how-to-use-typescript-in-create-react-app-application) | +| 140 | [What is reselect and how it works?](#what-is-reselect-and-how-it-works) | +| 141 | [What is Flow?](#what-is-flow) | +| 142 | [What is the difference between Flow and PropTypes?](#what-is-the-difference-between-flow-and-proptypes) | +| 143 | [How to use font-awesome icons in React?](#how-to-use-font-awesome-icons-in-react) | +| 144 | [What is React Dev Tools?](#what-is-react-dev-tools) | +| 145 | [Why is DevTools not loading in Chrome for local files?](#why-is-devtools-not-loading-in-chrome-for-local-files) | +| 146 | [How to use Polymer in React?](#how-to-use-polymer-in-react) | +| 147 | [What are the advantages of React over Vue.js?](#what-are-the-advantages-of-react-over-vuejs) | +| 148 | [What is the difference between React and Angular?](#what-is-the-difference-between-react-and-angular) | +| 149 | [Why React tab is not showing up in DevTools?](#why-react-tab-is-not-showing-up-in-devtools) | +| 150 | [What are styled components?](#what-are-styled-components) | +| 151 | [Give an example of Styled Components?](#give-an-example-of-styled-components) | +| 152 | [What is Relay?](#what-is-relay) | | | **Miscellaneous** | -| 206 | [What are the main features of reselect library?](#what-are-the-main-features-of-reselect-library) | -| 207 | [Give an example of reselect usage?](#give-an-example-of-reselect-usage) | -| 209 | [Does the statics object work with ES6 classes in React?](#does-the-statics-object-work-with-es6-classes-in-react) | -| 210 | [Can Redux only be used with React?](#can-redux-only-be-used-with-react) | -| 211 | [Do you need to have a particular build tool to use Redux?](#do-you-need-to-have-a-particular-build-tool-to-use-redux) | -| 212 | [How Redux Form initialValues get updated from state?](#how-redux-form-initialvalues-get-updated-from-state) | -| 213 | [How React PropTypes allow different type for one prop?](#how-react-proptypes-allow-different-types-for-one-prop) | -| 214 | [Can I import an SVG file as react component?](#can-i-import-an-svg-file-as-react-component) | -| 215 | [Why are inline ref callbacks or functions not recommended?](#why-are-inline-ref-callbacks-or-functions-not-recommended) | -| 216 | [What is render hijacking in React?](#what-is-render-hijacking-in-react) | -| 217 | [What are HOC factory implementations?](#what-are-hoc-factory-implementations) | -| 218 | [How to pass numbers to React component?](#how-to-pass-numbers-to-react-component) | -| 219 | [Do I need to keep all my state into Redux? Should I ever use react internal state?](#do-i-need-to-keep-all-my-state-into-redux-should-i-ever-use-react-internal-state) | -| 220 | [What is the purpose of registerServiceWorker in React?](#what-is-the-purpose-of-registerserviceworker-in-react) | -| 221 | [What is React memo function?](#what-is-react-memo-function) | -| 222 | [What is React lazy function?](#what-is-react-lazy-function) | -| 223 | [How to prevent unnecessary updates using setState?](#how-to-prevent-unnecessary-updates-using-setstate) | -| 224 | [How do you render Array, Strings and Numbers in React 16 Version?](#how-do-you-render-array-strings-and-numbers-in-react-16-version) | -| 225 | [How to use class field declarations syntax in React classes?](#how-to-use-class-field-declarations-syntax-in-react-classes) | -| 226 | [What are hooks?](#what-are-hooks) | -| 227 | [What rules need to be followed for hooks?](#what-rules-need-to-be-followed-for-hooks) | -| 228 | [How to ensure hooks followed the rules in your project?](#how-to-ensure-hooks-followed-the-rules-in-your-project) | -| 229 | [What are the differences between Flux and Redux?](#what-are-the-differences-between-flux-and-redux) | -| 230 | [What are the benefits of React Router V4?](#what-are-the-benefits-of-react-router-v4) | -| 231 | [Can you describe about componentDidCatch lifecycle method signature?](#can-you-describe-about-componentdidcatch-lifecycle-method-signature) | -| 232 | [In which scenarios error boundaries do not catch errors?](#in-which-scenarios-error-boundaries-do-not-catch-errors) | -| 233 | [Why do you not need error boundaries for event handlers?](#why-do-you-not-need-error-boundaries-for-event-handlers) | -| 234 | [What is the difference between try catch block and error boundaries?](#what-is-the-difference-between-try-catch-block-and-error-boundaries) | -| 235 | [What is the behavior of uncaught errors in react 16?](#what-is-the-behavior-of-uncaught-errors-in-react-16) | -| 236 | [What is the proper placement for error boundaries?](#what-is-the-proper-placement-for-error-boundaries) | -| 237 | [What is the benefit of component stack trace from error boundary?](#what-is-the-benefit-of-component-stack-trace-from-error-boundary) | -| 238 | [What is the required method to be defined for a class component?](#what-is-the-required-method-to-be-defined-for-a-class-component) | -| 239 | [What are the possible return types of render method?](#what-are-the-possible-return-types-of-render-method) | -| 240 | [What is the main purpose of constructor?](#what-is-the-main-purpose-of-constructor) | -| 241 | [Is it mandatory to define constructor for React component?](#is-it-mandatory-to-define-constructor-for-react-component) | -| 242 | [What are default props?](#what-are-default-props) | -| 243 | [Why should not call setState in componentWillUnmount?](#why-should-not-call-setstate-in-componentwillunmount) | -| 244 | [What is the purpose of getDerivedStateFromError?](#what-is-the-purpose-of-getderivedstatefromerror) | -| 245 | [What is the methods order when component re-rendered?](#what-is-the-methods-order-when-component-re-rendered) | -| 246 | [What are the methods invoked during error handling?](#what-are-the-methods-invoked-during-error-handling) | -| 247 | [What is the purpose of displayName class property?](#what-is-the-purpose-of-displayname-class-property) | -| 248 | [What is the browser support for react applications?](#what-is-the-browser-support-for-react-applications) | -| 249 | [What is the purpose of unmountComponentAtNode method?](#what-is-the-purpose-of-unmountcomponentatnode-method) | -| 250 | [What is code-splitting?](#what-is-code-splitting) | -| 251 | [What is the benefit of strict mode?](#what-is-the-benefit-of-strict-mode) | -| 252 | [What are Keyed Fragments?](#what-are-keyed-fragments) | -| 253 | [Does React support all HTML attributes?](#does-react-support-all-html-attributes) | -| 254 | [What are the limitations with HOCs?](#what-are-the-limitations-with-hocs) | -| 255 | [How to debug forwardRefs in DevTools?](#how-to-debug-forwardrefs-in-devtools) | -| 256 | [When component props defaults to true?](#when-component-props-defaults-to-true) | -| 257 | [What is NextJS and major features of it?](#what-is-nextjs-and-major-features-of-it) | -| 258 | [How do you pass an event handler to a component?](#how-do-you-pass-an-event-handler-to-a-component) | -| 259 | [Is it good to use arrow functions in render methods?](#is-it-good-to-use-arrow-functions-in-render-methods) | -| 260 | [How to prevent a function from being called multiple times?](#how-to-prevent-a-function-from-being-called-multiple-times) | -| 261 | [How JSX prevents Injection Attacks?](#how-jsx-prevents-injection-attacks) | -| 262 | [How do you update rendered elements?](#how-do-you-update-rendered-elements) | -| 263 | [How do you say that props are read only?](#how-do-you-say-that-props-are-read-only) | -| 264 | [How do you say that state updates are merged?](#how-do-you-say-that-state-updates-are-merged) | -| 265 | [How do you pass arguments to an event handler?](#how-do-you-pass-arguments-to-an-event-handler) | -| 266 | [How to prevent component from rendering?](#how-to-prevent-component-from-rendering) | -| 267 | [What are the conditions to safely use the index as a key?](#what-are-the-conditions-to-safely-use-the-index-as-a-key) | -| 268 | [Is it keys should be globally unique?](#is-it-keys-should-be-globally-unique) | -| 269 | [What is the popular choice for form handling?](#what-is-the-popular-choice-for-form-handling) | -| 270 | [What are the advantages of formik over redux form library?](#what-are-the-advantages-of-formik-over-redux-form-library) | -| 271 | [Why do you not required to use inheritance?](#why-do-you-not-required-to-use-inheritance) | -| 272 | [Can I use web components in react application?](#can-i-use-web-components-in-react-application) | -| 273 | [What is dynamic import?](#what-is-dynamic-import) | -| 274 | [What are loadable components?](#what-are-loadable-components) | -| 275 | [What is suspense component?](#what-is-suspense-component) | -| 276 | [What is route based code splitting?](#what-is-route-based-code-splitting) | -| 277 | [Give an example on How to use context?](#give-an-example-on-how-to-use-context) | -| 278 | [What is the purpose of default value in context?](#what-is-the-purpose-of-default-value-in-context) | -| 279 | [How do you use contextType?](#how-do-you-use-contexttype) | -| 280 | [What is a consumer?](#what-is-a-consumer) | -| 281 | [How do you solve performance corner cases while using context?](#how-do-you-solve-performance-corner-cases-while-using-context) | -| 282 | [What is the purpose of forward ref in HOCs?](#what-is-the-purpose-of-forward-ref-in-hocs) | -| 283 | [Is it ref argument available for all functions or class components?](#is-it-ref-argument-available-for-all-functions-or-class-components) | -| 284 | [Why do you need additional care for component libraries while using forward refs?](#why-do-you-need-additional-care-for-component-libraries-while-using-forward-refs) | -| 285 | [How to create react class components without ES6?](#how-to-create-react-class-components-without-es6) | -| 286 | [Is it possible to use react without JSX?](#is-it-possible-to-use-react-without-jsx) | -| 287 | [What is diffing algorithm?](#what-is-diffing-algorithm) | -| 288 | [What are the rules covered by diffing algorithm?](#what-are-the-rules-covered-by-diffing-algorithm) | -| 289 | [When do you need to use refs?](#when-do-you-need-to-use-refs) | -| 290 | [Is it prop must be named as render for render props?](#is-it-prop-must-be-named-as-render-for-render-props) | -| 291 | [What are the problems of using render props with pure components?](#what-are-the-problems-of-using-render-props-with-pure-components) | -| 292 | [How do you create HOC using render props?](#how-do-you-create-hoc-using-render-props) | -| 293 | [What is windowing technique?](#what-is-windowing-technique) | -| 294 | [How do you print falsy values in JSX?](#how-do-you-print-falsy-values-in-jsx) | -| 295 | [What is the typical use case of portals?](#what-is-the-typical-use-case-of-portals) | -| 296 | [How do you set default value for uncontrolled component?](#how-do-you-set-default-value-for-uncontrolled-component) | -| 297 | [What is your favorite React stack?](#what-is-your-favorite-react-stack) | -| 298 | [What is the difference between Real DOM and Virtual DOM?](#what-is-the-difference-between-real-dom-and-virtual-dom) | -| 299 | [How to add Bootstrap to a react application?](#how-to-add-bootstrap-to-a-react-application) | -| 300 | [Can you list down top websites or applications using react as front end framework?](#can-you-list-down-top-websites-or-applications-using-react-as-front-end-framework) | -| 301 | [Is it recommended to use CSS In JS technique in React?](#is-it-recommended-to-use-css-in-js-technique-in-react) | -| 302 | [Do I need to rewrite all my class components with hooks?](#do-i-need-to-rewrite-all-my-class-components-with-hooks) | -| 303 | [How to fetch data with React Hooks?](#how-to-fetch-data-with-react-hooks) | -| 304 | [Is Hooks cover all use cases for classes?](#is-hooks-cover-all-use-cases-for-classes) | -| 305 | [What is the stable release for hooks support?](#what-is-the-stable-release-for-hooks-support) | -| 306 | [Why do we use array destructuring (square brackets notation) in useState?](#why-do-we-use-array-destructuring-square-brackets-notation-in-usestate) | -| 307 | [What are the sources used for introducing hooks?](#what-are-the-sources-used-for-introducing-hooks) | -| 308 | [How do you access imperative API of web components?](#how-do-you-access-imperative-api-of-web-components) | -| 309 | [What is formik?](#what-is-formik) | -| 310 | [What are typical middleware choices for handling asynchronous calls in Redux?](#what-are-typical-middleware-choices-for-handling-asynchronous-calls-in-redux) | -| 311 | [Do browsers understand JSX code?](#do-browsers-understand-jsx-code) | -| 312 | [Describe about data flow in react?](#describe-about-data-flow-in-react) | -| 313 | [What is react scripts?](#what-is-react-scripts) | -| 314 | [What are the features of create react app?](#what-are-the-features-of-create-react-app) | -| 315 | [What is the purpose of renderToNodeStream method?](#what-is-the-purpose-of-rendertonodestream-method) | -| 316 | [What is MobX?](#what-is-mobx) | -| 317 | [What are the differences between Redux and MobX?](#what-are-the-differences-between-redux-and-mobx) | -| 318 | [Should I learn ES6 before learning ReactJS?](#should-i-learn-es6-before-learning-reactjs) | -| 319 | [What is Concurrent Rendering?](#what-is-concurrent-rendering) | -| 320 | [What is the difference between async mode and concurrent mode?](#what-is-the-difference-between-async-mode-and-concurrent-mode) | -| 321 | [Can I use javascript urls in react16.9?](#can-i-use-javascript-urls-in-react169) | -| 322 | [What is the purpose of eslint plugin for hooks?](#what-is-the-purpose-of-eslint-plugin-for-hooks) | -| 323 | [What is the difference between Imperative and Declarative in React?](#what-is-the-difference-between-imperative-and-declarative-in-react) | -| 324 | [What are the benefits of using typescript with reactjs?](#what-are-the-benefits-of-using-typescript-with-reactjs) | -| 325 | [How do you make sure that user remains authenticated on page refresh while using Context API State Management?](#how-do-you-make-sure-that-user-remains-authenticated-on-page-refresh-while-using-context-api-state-management) | -| 326 | [What are the benefits of new JSX transform?](#what-are-the-benefits-of-new-jsx-transform) | -| 327 | [How is the new JSX transform different from old transform?](#how-is-the-new-jsx-transform-different-from-old-transform) | -| 328 | [How do you get redux scaffolding using create-react-app?](#how-do-you-get-redux-scaffolding-using-create-react-app) | -| 329 | [What are React Server components?](#what-are-react-server-components) | -| 330 | [What is prop drilling?](#what-is-prop-drilling) | -| 331 | [What is state mutation and how to prevent it?](#what-is-state-mutation-and-how-to-prevent-it) | -| 332 | [What is the difference between useState and useRef hook?](#what-is-the-difference-between-usestate-and-useref-hook) | -| 333 | [What is a wrapper component ](#what-is-a-wrapper-component) | -| 334 | [What are the differences between useEffect and useLayoutEffect hooks](#what-are-the-differences-between-useEffect-and-useLayoutEffect-hooks) | -| 335 | [What are the differences between Functional and Class Components ](#what-are-the-differences-between-functional-and-class-components) | -| 336 | [What is strict mode in React?](#what-is-strict-mode-in-react) -| 337 | [What is the benefit of strict mode?](#what-is-the-benefit-of-strict-mode) | -| 338 | [Why does strict mode render twice in React?](#why-does-strict-mode-render-twice-in-react)| -| 339 | [What are the rules of JSX?](#what-are-the-rules-of-JSX) | -| 340 | [What is the reason behind multiple JSX tags to be wrapped?](#what-is-the-reason-behind-multiple-JSX-tags-to-be-wrapped) | -| 341 | [How do you prevent mutating array variables?](#how-do-you-prevent-mutating-array-variables) | -| 342 | [What are capture phase events?](#what-are-capture-phase-events) | -| 343 | [How does React updates screen in an application?](#how-does-react-updates-screen-in-an-application) | -| 344 | [How does React batch multiple state updates?](#how-does-react-batch-multiple-state-updates) | -| 345 | [Is it possible to prevent automatic batching?](#is-it-possible-to-prevent-automatic-batching) | -| 346 | [What is React hydration?](#what-is-react-hydration) | -| 347 | [How do you update objects inside state?](#how-do-you-update-objects-inside-state) | -| 348 | [How do you update nested objects inside state?](#How-do-you-update-nested-objects-inside-state) | -| 349 | [How do you update arrays inside state?](#how-do-you-update-arrays-inside-state) | -| 350 | [How do you use immer library for state updates?](#how-do-you-use-immer-library-for-state-updates) | -| 351 | [What are the benefits of preventing the direct state mutations?](#what-are-the-benefits-of-preventing-the-direct-state-mutations) | -| 352 | [What are the preferred and non-preferred array operations for updating the state?](#what-are-the-preferred-and-non-preferred-array-operations-for-updating-the-state) | +| 153 | [What are the main features of reselect library?](#what-are-the-main-features-of-reselect-library) | +| 154 | [Give an example of reselect usage?](#give-an-example-of-reselect-usage) | +| 155 | [Can Redux only be used with React?](#can-redux-only-be-used-with-react) | +| 156 | [Do you need to have a particular build tool to use Redux?](#do-you-need-to-have-a-particular-build-tool-to-use-redux) | +| 157 | [How Redux Form initialValues get updated from state?](#how-redux-form-initialvalues-get-updated-from-state) | +| 158 | [How React PropTypes allow different type for one prop?](#how-react-proptypes-allow-different-types-for-one-prop) | +| 159 | [Can I import an SVG file as react component?](#can-i-import-an-svg-file-as-react-component) | +| 160 | [What is render hijacking in React?](#what-is-render-hijacking-in-react) | +| 161 | [How to pass numbers to React component?](#how-to-pass-numbers-to-react-component) | +| 162 | [Do I need to keep all my state into Redux? Should I ever use react internal state?](#do-i-need-to-keep-all-my-state-into-redux-should-i-ever-use-react-internal-state) | +| 163 | [What is the purpose of registerServiceWorker in React?](#what-is-the-purpose-of-registerserviceworker-in-react) | +| 164 | [What is React memo function?](#what-is-react-memo-function) | +| 165 | [What is React lazy function?](#what-is-react-lazy-function) | +| 166 | [How to prevent unnecessary updates using setState?](#how-to-prevent-unnecessary-updates-using-setstate) | +| 167 | [How do you render Array, Strings and Numbers in React 16 Version?](#how-do-you-render-array-strings-and-numbers-in-react-16-version) | +| 168 | [What are hooks?](#what-are-hooks) | +| 169 | [What rules need to be followed for hooks?](#what-rules-need-to-be-followed-for-hooks) | +| 170 | [How to ensure hooks followed the rules in your project?](#how-to-ensure-hooks-followed-the-rules-in-your-project) | +| 171 | [What are the differences between Flux and Redux?](#what-are-the-differences-between-flux-and-redux) | +| 172 | [What are the benefits of React Router V4?](#what-are-the-benefits-of-react-router-v4) | +| 173 | [Can you describe about componentDidCatch lifecycle method signature?](#can-you-describe-about-componentdidcatch-lifecycle-method-signature) | +| 174 | [In which scenarios error boundaries do not catch errors?](#in-which-scenarios-error-boundaries-do-not-catch-errors) | +| 175 | [What is the behavior of uncaught errors in react 16?](#what-is-the-behavior-of-uncaught-errors-in-react-16) | +| 176 | [What is the proper placement for error boundaries?](#what-is-the-proper-placement-for-error-boundaries) | +| 177 | [What is the benefit of component stack trace from error boundary?](#what-is-the-benefit-of-component-stack-trace-from-error-boundary) | +| 178 | [What are default props?](#what-are-default-props) | +| 179 | [What is the purpose of displayName class property?](#what-is-the-purpose-of-displayname-class-property) | +| 180 | [What is the browser support for react applications?](#what-is-the-browser-support-for-react-applications) | +| 181 | [What is code-splitting?](#what-is-code-splitting) | +| 182 | [What are Keyed Fragments?](#what-are-keyed-fragments) | +| 183 | [Does React support all HTML attributes?](#does-react-support-all-html-attributes) | +| 184 | [When component props defaults to true?](#when-component-props-defaults-to-true) | +| 185 | [What is NextJS and major features of it?](#what-is-nextjs-and-major-features-of-it) | +| 186 | [How do you pass an event handler to a component?](#how-do-you-pass-an-event-handler-to-a-component) | +| 187 | [How to prevent a function from being called multiple times?](#how-to-prevent-a-function-from-being-called-multiple-times) | +| 188 | [How JSX prevents Injection Attacks?](#how-jsx-prevents-injection-attacks) | +| 189 | [How do you update rendered elements?](#how-do-you-update-rendered-elements) | +| 190 | [How do you say that props are read only?](#how-do-you-say-that-props-are-read-only) | +| 191 | [What are the conditions to safely use the index as a key?](#what-are-the-conditions-to-safely-use-the-index-as-a-key) | +| 192 | [Is it keys should be globally unique?](#is-it-keys-should-be-globally-unique) | +| 193 | [What is the popular choice for form handling?](#what-is-the-popular-choice-for-form-handling) | +| 194 | [What are the advantages of formik over redux form library?](#what-are-the-advantages-of-formik-over-redux-form-library) | +| 195 | [Why do you not required to use inheritance?](#why-do-you-not-required-to-use-inheritance) | +| 196 | [Can I use web components in react application?](#can-i-use-web-components-in-react-application) | +| 197 | [What is dynamic import?](#what-is-dynamic-import) | +| 198 | [What are loadable components?](#what-are-loadable-components) | +| 199 | [What is suspense component?](#what-is-suspense-component) | +| 200 | [What is route based code splitting?](#what-is-route-based-code-splitting) | +| 201 | [What is the purpose of default value in context?](#what-is-the-purpose-of-default-value-in-context) | +| 202 | [What is diffing algorithm?](#what-is-diffing-algorithm) | +| 203 | [What are the rules covered by diffing algorithm?](#what-are-the-rules-covered-by-diffing-algorithm) | +| 204 | [When do you need to use refs?](#when-do-you-need-to-use-refs) | +| 205 | [Is it prop must be named as render for render props?](#is-it-prop-must-be-named-as-render-for-render-props) | +| 206 | [What are the problems of using render props with pure components?](#what-are-the-problems-of-using-render-props-with-pure-components) | +| 207 | [What is windowing technique?](#what-is-windowing-technique) | +| 208 | [How do you print falsy values in JSX?](#how-do-you-print-falsy-values-in-jsx) | +| 209 | [What is the typical use case of portals?](#what-is-the-typical-use-case-of-portals) | +| 210 | [How do you set default value for uncontrolled component?](#how-do-you-set-default-value-for-uncontrolled-component) | +| 211 | [What is your favorite React stack?](#what-is-your-favorite-react-stack) | +| 212 | [What is the difference between Real DOM and Virtual DOM?](#what-is-the-difference-between-real-dom-and-virtual-dom) | +| 213 | [How to add Bootstrap to a react application?](#how-to-add-bootstrap-to-a-react-application) | +| 214 | [Can you list down top websites or applications using react as front end framework?](#can-you-list-down-top-websites-or-applications-using-react-as-front-end-framework) | +| 215 | [Is it recommended to use CSS In JS technique in React?](#is-it-recommended-to-use-css-in-js-technique-in-react) | +| 216 | [Do I need to rewrite all my class components with hooks?](#do-i-need-to-rewrite-all-my-class-components-with-hooks) | +| 217 | [How to fetch data with React Hooks?](#how-to-fetch-data-with-react-hooks) | +| 218 | [Is Hooks cover all use cases for classes?](#is-hooks-cover-all-use-cases-for-classes) | +| 219 | [What is the stable release for hooks support?](#what-is-the-stable-release-for-hooks-support) | +| 220 | [Why do we use array destructuring (square brackets notation) in useState?](#why-do-we-use-array-destructuring-square-brackets-notation-in-usestate) | +| 221 | [What are the sources used for introducing hooks?](#what-are-the-sources-used-for-introducing-hooks) | +| 222 | [How do you access imperative API of web components?](#how-do-you-access-imperative-api-of-web-components) | +| 223 | [What is formik?](#what-is-formik) | +| 224 | [What are typical middleware choices for handling asynchronous calls in Redux?](#what-are-typical-middleware-choices-for-handling-asynchronous-calls-in-redux) | +| 225 | [Do browsers understand JSX code?](#do-browsers-understand-jsx-code) | +| 226 | [Describe about data flow in react?](#describe-about-data-flow-in-react) | +| 227 | [What is MobX?](#what-is-mobx) | +| 228 | [What are the differences between Redux and MobX?](#what-are-the-differences-between-redux-and-mobx) | +| 229 | [Should I learn ES6 before learning ReactJS?](#should-i-learn-es6-before-learning-reactjs) | +| 230 | [What is Concurrent Rendering?](#what-is-concurrent-rendering) | +| 231 | [What is the difference between async mode and concurrent mode?](#what-is-the-difference-between-async-mode-and-concurrent-mode) | +| 232 | [Can I use javascript urls in react16.9?](#can-i-use-javascript-urls-in-react169) | +| 233 | [What is the purpose of eslint plugin for hooks?](#what-is-the-purpose-of-eslint-plugin-for-hooks) | +| 234 | [What is the difference between Imperative and Declarative in React?](#what-is-the-difference-between-imperative-and-declarative-in-react) | +| 235 | [What are the benefits of using typescript with reactjs?](#what-are-the-benefits-of-using-typescript-with-reactjs) | +| 236 | [How do you make sure that user remains authenticated on page refresh while using Context API State Management?](#how-do-you-make-sure-that-user-remains-authenticated-on-page-refresh-while-using-context-api-state-management) | +| 237 | [What are the benefits of new JSX transform?](#what-are-the-benefits-of-new-jsx-transform) | +| 238 | [How is the new JSX transform different from old transform?](#how-is-the-new-jsx-transform-different-from-old-transform) | +| 239 | [What are React Server components?](#what-are-react-server-components) | +| 240 | [What is prop drilling?](#what-is-prop-drilling) | +| 241 | [What is the difference between useState and useRef hook?](#what-is-the-difference-between-usestate-and-useref-hook) | +| 242 | [What is a wrapper component ](#what-is-a-wrapper-component) | +| 243 | [What are the differences between useEffect and useLayoutEffect hooks](#what-are-the-differences-between-useEffect-and-useLayoutEffect-hooks) | +| 244 | [What are the differences between Functional and Class Components ](#what-are-the-differences-between-functional-and-class-components) | +| 245 | [What is strict mode in React?](#what-is-strict-mode-in-react) +| 246 | [What is the benefit of strict mode?](#what-is-the-benefit-of-strict-mode) | +| 247 | [Why does strict mode render twice in React?](#why-does-strict-mode-render-twice-in-react)| +| 248 | [What are the rules of JSX?](#what-are-the-rules-of-JSX) | +| 249 | [What is the reason behind multiple JSX tags to be wrapped?](#what-is-the-reason-behind-multiple-JSX-tags-to-be-wrapped) | +| 250 | [How do you prevent mutating array variables?](#how-do-you-prevent-mutating-array-variables) | +| 251 | [What are capture phase events?](#what-are-capture-phase-events) | +| 252 | [How does React updates screen in an application?](#how-does-react-updates-screen-in-an-application) | +| 253 | [How does React batch multiple state updates?](#how-does-react-batch-multiple-state-updates) | +| 254 | [Is it possible to prevent automatic batching?](#is-it-possible-to-prevent-automatic-batching) | +| 255 | [What is React hydration?](#what-is-react-hydration) | +| 256 | [How do you update objects inside state?](#how-do-you-update-objects-inside-state) | +| 257 | [How do you update nested objects inside state?](#How-do-you-update-nested-objects-inside-state) | +| 258 | [How do you update arrays inside state?](#how-do-you-update-arrays-inside-state) | +| 259 | [How do you use immer library for state updates?](#how-do-you-use-immer-library-for-state-updates) | +| 260 | [What are the benefits of preventing the direct state mutations?](#what-are-the-benefits-of-preventing-the-direct-state-mutations) | +| 261 | [What are the preferred and non-preferred array operations for updating the state?](#what-are-the-preferred-and-non-preferred-array-operations-for-updating-the-state) | +| 262 | [What will happen by defining nested function components?](#what-will-happen-by-defining-nested-function-components) | +| 263 | [Can I use keys for non-list items?](#can-i-use-keys-for-non-list-items)| +| 264 | [What are the guidelines to be followed for writing reducers?](#what-are-the-guidelines-to-be-followed-for-writing-reducers) | +| 265 | [What is useReducer hook? Can you describe its usage?](#what-is-use-reducer-hook-Can-you-describe-its-usage)| +| 266 | [How do you compare useState and useReducer?](#how-do-you-compare-use-state-and-use-reducer)| +| 267 | [How does context works using useContext hook?](#how-does-context-works-using-use-context-hook)| +| 268 | [What are the use cases of useContext hook?](#what-are-the-use-cases-of-use-context-hook)| + + +### Table of Contents + +
    + +Hide/Show table of contents + +| No. | Questions | +| --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| | **Old Q&A** | +| 1 | [Why should we not update the state directly?](#why-should-we-not-update-the-state-directly) | +| 2 | [What is the purpose of callback function as an argument of setState()?](#what-is-the-purpose-of-callback-function-as-an-argument-of-setstate) | +| 3 | [How to bind methods or event handlers in JSX callbacks?](#how-to-bind-methods-or-event-handlers-in-jsx-callbacks) | +| 4 | [How to pass a parameter to an event handler or callback?](#how-to-pass-a-parameter-to-an-event-handler-or-callback) | +| 5 | [What is the use of refs?](#what-is-the-use-of-refs) | +| 6 | [How to create refs?](#how-to-create-refs) | +| 7 | [What are forward refs?](#what-are-forward-refs) | +| 8 | [Which is preferred option with in callback refs and findDOMNode()?](#which-is-preferred-option-with-in-callback-refs-and-finddomnode) | +| 9 | [Why are String Refs legacy?](#why-are-string-refs-legacy) | +| 10 | [What are the different phases of component lifecycle?](#what-are-the-different-phases-of-component-lifecycle) | +| 11 | [What are the lifecycle methods of React?](#what-are-the-lifecycle-methods-of-react) | +| 12 | [How to create props proxy for HOC component?](#how-to-create-props-proxy-for-hoc-component) | +| 13 | [What is context?](#what-is-context) | +| 14 | [What is the purpose of using super constructor with props argument?](#what-is-the-purpose-of-using-super-constructor-with-props-argument) | +| 15 | [How to set state with a dynamic key name?](#how-to-set-state-with-a-dynamic-key-name) | +| 16 | [What would be the common mistake of function being called every time the component renders?](#what-would-be-the-common-mistake-of-function-being-called-every-time-the-component-renders) | +| 17 | [What are error boundaries in React v16](#what-are-error-boundaries-in-react-v16) | +| 18 | [How are error boundaries handled in React v15?](#how-are-error-boundaries-handled-in-react-v15) | +| 19 | [What is the purpose of render method of react-dom?](#what-is-the-purpose-of-render-method-of-react-dom) | +| 20 | [What will happen if you use setState in constructor?](#what-will-happen-if-you-use-setstate-in-constructor) | +| 21 | [Is it good to use setState() in componentWillMount() method?](#is-it-good-to-use-setstate-in-componentwillmount-method) | +| 22 | [What will happen if you use props in initial state?](#what-will-happen-if-you-use-props-in-initial-state) | +| 23 | [How you use decorators in React?](#how-you-use-decorators-in-react) | +| 24 | [What is CRA and its benefits?](#what-is-cra-and-its-benefits) | +| 25 | [What is the lifecycle methods order in mounting?](#what-is-the-lifecycle-methods-order-in-mounting) | +| 26 | [What are the lifecycle methods going to be deprecated in React v16?](#what-are-the-lifecycle-methods-going-to-be-deprecated-in-react-v16) | +| 27 | [What is the purpose of getDerivedStateFromProps() lifecycle method?](#what-is-the-purpose-of-getderivedstatefromprops-lifecycle-method) | +| 28 | [What is the purpose of getSnapshotBeforeUpdate() lifecycle method?](#what-is-the-purpose-of-getsnapshotbeforeupdate-lifecycle-method) | +| 29 | [What is the recommended way for naming components?](#what-is-the-recommended-way-for-naming-components) | +| 30 | [What is the recommended ordering of methods in component class?](#what-is-the-recommended-ordering-of-methods-in-component-class) | +| 31 | [Why we need to pass a function to setState()?](#why-we-need-to-pass-a-function-to-setstate) | +| 32 | [Why is isMounted() an anti-pattern and what is the proper solution?](#why-is-ismounted-an-anti-pattern-and-what-is-the-proper-solution) | +| 33 | [What is the difference between constructor and getInitialState?](#what-is-the-difference-between-constructor-and-getinitialstate) | +| 34 | [Can you force a component to re-render without calling setState?](#can-you-force-a-component-to-re-render-without-calling-setstate) | +| 35 | [What is the difference between super() and super(props) in React using ES6 classes?](#what-is-the-difference-between-super-and-superprops-in-react-using-es6-classes) | +| 36 | [What is the difference between setState and replaceState methods?](#what-is-the-difference-between-setstate-and-replacestate-methods) | +| 37 | [How to listen to state changes?](#how-to-listen-to-state-changes) | +| 38 | [What is the recommended approach of removing an array element in react state?](#what-is-the-recommended-approach-of-removing-an-array-element-in-react-state) | +| 39 | [Is it possible to use React without rendering HTML?](#is-it-possible-to-use-react-without-rendering-html) | +| 40 | [What are the possible ways of updating objects in state?](#what-are-the-possible-ways-of-updating-objects-in-state) | +| 41 | [What are the approaches to include polyfills in your create-react-app?](#what-are-the-approaches-to-include-polyfills-in-your-create-react-app) | +| 42 | [How to use https instead of http in create-react-app?](#how-to-use-https-instead-of-http-in-create-react-app) | +| 43 | [How to avoid using relative path imports in create-react-app?](#how-to-avoid-using-relative-path-imports-in-create-react-app) | +| 44 | [How to update a component every second?](#how-to-update-a-component-every-second) | +| 45 | [Why is a component constructor called only once?](#why-is-a-component-constructor-called-only-once) | +| 46 | [How to define constants in React?](#how-to-define-constants-in-react) | +| 47 | [How to programmatically trigger click event in React?](#how-to-programmatically-trigger-click-event-in-react) | +| 48 | [How to make AJAX call and In which component lifecycle methods should I make an AJAX call?](#how-to-make-ajax-call-and-in-which-component-lifecycle-methods-should-i-make-an-ajax-call) | +| 49 | [What are render props?](#what-are-render-props) | +| 50 | [How to dispatch an action on load?](#how-to-dispatch-an-action-on-load) | +| 51 | [How to use connect from React Redux?](#how-to-use-connect-from-react-redux) | +| 52 | [Whats the purpose of at symbol in the redux connect decorator?](#whats-the-purpose-of-at-symbol-in-the-redux-connect-decorator) | +| 53 | [How to use TypeScript in create-react-app application?](#how-to-use-typescript-in-create-react-app-application) | +| 54 | [Does the statics object work with ES6 classes in React?](#does-the-statics-object-work-with-es6-classes-in-react) | +| 55 | [Why are inline ref callbacks or functions not recommended?](#why-are-inline-ref-callbacks-or-functions-not-recommended) | +| 56 | [What are HOC factory implementations?](#what-are-hoc-factory-implementations) | +| 57 | [How to use class field declarations syntax in React classes?](#how-to-use-class-field-declarations-syntax-in-react-classes) | +| 58 | [Why do you not need error boundaries for event handlers?](#why-do-you-not-need-error-boundaries-for-event-handlers) | +| 59 | [What is the difference between try catch block and error boundaries?](#what-is-the-difference-between-try-catch-block-and-error-boundaries) | +| 60 | [What is the required method to be defined for a class component?](#what-is-the-required-method-to-be-defined-for-a-class-component) | +| 61 | [What are the possible return types of render method?](#what-are-the-possible-return-types-of-render-method) | +| 62 | [What is the main purpose of constructor?](#what-is-the-main-purpose-of-constructor) | +| 63 | [Is it mandatory to define constructor for React component?](#is-it-mandatory-to-define-constructor-for-react-component) | +| 64 | [Why should not call setState in componentWillUnmount?](#why-should-not-call-setstate-in-componentwillunmount) | +| 65 | [What is the purpose of getDerivedStateFromError?](#what-is-the-purpose-of-getderivedstatefromerror) | +| 66 | [What is the methods order when component re-rendered?](#what-is-the-methods-order-when-component-re-rendered) | +| 67 | [What are the methods invoked during error handling?](#what-are-the-methods-invoked-during-error-handling) | +| 68 | [What is the purpose of unmountComponentAtNode method?](#what-is-the-purpose-of-unmountcomponentatnode-method) | +| 69 | [What are the limitations with HOCs?](#what-are-the-limitations-with-hocs) | +| 70 | [How to debug forwardRefs in DevTools?](#how-to-debug-forwardrefs-in-devtools) | +| 71 | [Is it good to use arrow functions in render methods?](#is-it-good-to-use-arrow-functions-in-render-methods) | +| 72 | [How do you say that state updates are merged?](#how-do-you-say-that-state-updates-are-merged) | +| 73 | [How do you pass arguments to an event handler?](#how-do-you-pass-arguments-to-an-event-handler) | +| 74 | [How to prevent component from rendering?](#how-to-prevent-component-from-rendering) | +| 75 | [Give an example on How to use context?](#give-an-example-on-how-to-use-context) | +| 76 | [How do you use contextType?](#how-do-you-use-contexttype) | +| 77 | [What is a consumer?](#what-is-a-consumer) | +| 78 | [How do you solve performance corner cases while using context?](#how-do-you-solve-performance-corner-cases-while-using-context) | +| 79 | [What is the purpose of forward ref in HOCs?](#what-is-the-purpose-of-forward-ref-in-hocs) | +| 80 | [Is it ref argument available for all functions or class components?](#is-it-ref-argument-available-for-all-functions-or-class-components) | +| 81 | [Why do you need additional care for component libraries while using forward refs?](#why-do-you-need-additional-care-for-component-libraries-while-using-forward-refs) | +| 82 | [How to create react class components without ES6?](#how-to-create-react-class-components-without-es6) | +| 83 | [Is it possible to use react without JSX?](#is-it-possible-to-use-react-without-jsx) | +| 84 | [How do you create HOC using render props?](#how-do-you-create-hoc-using-render-props) | +| 85 | [What is react scripts?](#what-is-react-scripts) | +| 86 | [What are the features of create react app?](#what-are-the-features-of-create-react-app) | +| 87 | [What is the purpose of renderToNodeStream method?](#what-is-the-purpose-of-rendertonodestream-method) | +| 88 | [How do you get redux scaffolding using create-react-app?](#how-do-you-get-redux-scaffolding-using-create-react-app) | +| 89 | [What is state mutation and how to prevent it?](#what-is-state-mutation-and-how-to-prevent-it) |
    ## Core React @@ -422,7 +439,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -2. ### What are the major features of React? +3. ### What are the major features of React? The major features of React are: @@ -434,7 +451,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -3. ### What is JSX? +4. ### What is JSX? _JSX_ stands for _JavaScript XML_ and it is an XML-like syntax extension to ECMAScript. Basically it just provides the syntactic sugar for the `React.createElement(type, props, ...children)` function, giving us expressiveness of JavaScript along with HTML like template syntax. @@ -481,7 +498,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -4. ### What is the difference between Element and Component? +5. ### What is the difference between Element and Component? An _Element_ is a plain object describing what you want to appear on the screen in terms of the DOM nodes or other components. _Elements_ can contain other _Elements_ in their props. Creating a React element is cheap. Once an element is created, it cannot be mutated. @@ -533,7 +550,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -5. ### How to create components in React? +6. ### How to create components in React? Components are the building blocks of creating User Interfaces(UI) in React. There are two possible ways to create a component. @@ -557,7 +574,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -6. ### When to use a Class Component over a Function Component? +7. ### When to use a Class Component over a Function Component? After the addition of Hooks(i.e. React 16.8 onwards) it is always recommended to use Function components over Class components in React. Because you could use state, lifecycle methods and other features that were only available in class component present in function component too. @@ -567,6 +584,7 @@ Hide/Show table of contents 2. In older versions, If the component needs _state or lifecycle methods_ then you need to use class component. So the summary to this question is as follows: + **Use Function Components:** - If you don't need state or lifecycle methods, and your component is purely presentational. @@ -795,7 +813,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -10. ### What is the difference between state and props? +11. ### What is the difference between state and props? In React, both `state` and `props` are plain JavaScript objects and used to manage the data of a component, but they are used in different ways and have different characteristics. @@ -805,41 +823,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -11. ### Why should we not update the state directly? - - If you try to update the state directly then it won't re-render the component. - - ```javascript - //Wrong - this.state.message = "Hello world"; - ``` - - Instead use `setState()` method. It schedules an update to a component's state object. When state changes, the component responds by re-rendering. - - ```javascript - //Correct - this.setState({ message: "Hello World" }); - ``` - - **Note:** You can directly assign to the state object either in _constructor_ or using latest javascript's class field declaration syntax. - - **[⬆ Back to Top](#table-of-contents)** - -12. ### What is the purpose of callback function as an argument of `setState()`? - - The callback function is invoked when setState finished and the component gets rendered. Since `setState()` is **asynchronous** the callback function is used for any post action. - - **Note:** It is recommended to use lifecycle method rather than this callback function. - - ```javascript - setState({ name: "John" }, () => - console.log("The name has updated and component re-rendered") - ); - ``` - - **[⬆ Back to Top](#table-of-contents)** - -13. ### What is the difference between HTML and React event handling? +12. ### What is the difference between HTML and React event handling? Below are some of the main differences between HTML and React event handling, @@ -878,80 +862,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -14. ### How to bind methods or event handlers in JSX callbacks? - - There are 3 possible ways to achieve this in class components: - - 1. **Binding in Constructor:** In JavaScript classes, the methods are not bound by default. The same rule applies for React event handlers defined as class methods. Normally we bind them in constructor. - - ```javascript - class User extends Component { - constructor(props) { - super(props); - this.handleClick = this.handleClick.bind(this); - } - handleClick() { - console.log("SingOut triggered"); - } - render() { - return ; - } - } - ``` - - 2. **Public class fields syntax:** If you don't like to use bind approach then _public class fields syntax_ can be used to correctly bind callbacks. The Create React App enables this syntax by default. - - ```jsx harmony - handleClick = () => { - console.log("SingOut triggered", this); - }; - ``` - - ```jsx harmony - - ``` - - 3. **Arrow functions in callbacks:** It is possible to use _arrow functions_ directly in the callbacks. - - ```jsx harmony - handleClick() { - console.log('SingOut triggered'); - } - render() { - return ; - } - ``` - - **Note:** If the callback is passed as prop to child components, those components might do an extra re-rendering. In those cases, it is preferred to go with `.bind()` or _public class fields syntax_ approach considering performance. - - **[⬆ Back to Top](#table-of-contents)** - -15. ### How to pass a parameter to an event handler or callback? - - You can use an _arrow function_ to wrap around an _event handler_ and pass parameters: - - ```jsx harmony - - )); - - // Create ref to the DOM button: - const ref = React.createRef(); - {"Forward Ref"}; - ``` - - **[⬆ Back to Top](#table-of-contents)** - -22. ### Which is preferred option with in callback refs and findDOMNode()? - - It is preferred to use _callback refs_ over `findDOMNode()` API. Because `findDOMNode()` prevents certain improvements in React in the future. - - The **legacy** approach of using `findDOMNode`: - - ```javascript - class MyComponent extends Component { - componentDidMount() { - findDOMNode(this).scrollIntoView(); - } - - render() { - return
    ; - } - } - ``` - - The recommended approach is: - - ```javascript - class MyComponent extends Component { - constructor(props) { - super(props); - this.node = createRef(); - } - componentDidMount() { - this.node.current.scrollIntoView(); - } - - render() { - return
    ; - } - } - ``` - - **[⬆ Back to Top](#table-of-contents)** - -23. ### Why are String Refs legacy? - - If you worked with React before, you might be familiar with an older API where the `ref` attribute is a string, like `ref={'textInput'}`, and the DOM node is accessed as `this.refs.textInput`. We advise against it because _string refs have below issues_, and are considered legacy. String refs were **removed in React v16**. - - 1. They _force React to keep track of currently executing component_. This is problematic because it makes react module stateful, and thus causes weird errors when react module is duplicated in the bundle. - 2. They are _not composable_ — if a library puts a ref on the passed child, the user can't put another ref on it. Callback refs are perfectly composable. - 3. They _don't work with static analysis_ like Flow. Flow can't guess the magic that framework does to make the string ref appear on `this.refs`, as well as its type (which could be different). Callback refs are friendlier to static analysis. - 4. It doesn't work as most people would expect with the "render callback" pattern (e.g. ) - - ```jsx harmony - class MyComponent extends Component { - renderRow = (index) => { - // This won't work. Ref will get attached to DataTable rather than MyComponent: - return ; - - // This would work though! Callback refs are awesome. - return (this["input-" + index] = input)} />; - }; - - render() { - return ( - - ); - } - } - ``` - - **[⬆ Back to Top](#table-of-contents)** - -24. ### What is Virtual DOM? +16. ### What is Virtual DOM? The _Virtual DOM_ (VDOM) is an in-memory representation of _Real DOM_. The representation of a UI is kept in memory and synced with the "real" DOM. It's a step that happens between the render function being called and the displaying of elements on the screen. This entire process is called _reconciliation_. **[⬆ Back to Top](#table-of-contents)** -25. ### How Virtual DOM works? +17. ### How Virtual DOM works? The _Virtual DOM_ works in three simple steps. @@ -1183,19 +954,19 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -26. ### What is the difference between Shadow DOM and Virtual DOM? +18. ### What is the difference between Shadow DOM and Virtual DOM? The _Shadow DOM_ is a browser technology designed primarily for scoping variables and CSS in _web components_. The _Virtual DOM_ is a concept implemented by libraries in JavaScript on top of browser APIs. **[⬆ Back to Top](#table-of-contents)** -27. ### What is React Fiber? +19. ### What is React Fiber? Fiber is the new _reconciliation_ engine or reimplementation of core algorithm in React v16. The goal of React Fiber is to increase its suitability for areas like animation, layout, gestures, ability to pause, abort, or reuse work and assign priority to different types of updates; and new concurrency primitives. **[⬆ Back to Top](#table-of-contents)** -28. ### What is the main goal of React Fiber? +20. ### What is the main goal of React Fiber? The goal of _React Fiber_ is to increase its suitability for areas like animation, layout, and gestures. Its headline feature is **incremental rendering**: the ability to split rendering work into chunks and spread it out over multiple frames. @@ -1211,7 +982,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -29. ### What are controlled components? +21. ### What are controlled components? A component that controls the input elements within the forms on subsequent user input is called **Controlled Component**, i.e, every state mutation will have an associated handler function. That means, the displayed data is always in sync with the state of the component. @@ -1247,7 +1018,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -30. ### What are uncontrolled components? +22. ### What are uncontrolled components? The **Uncontrolled Components** are the ones that store their own state internally, and you query the DOM using a ref to find its current value when you need it. This is a bit more like traditional HTML. @@ -1316,74 +1087,23 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -31. ### What is the difference between createElement and cloneElement? +23. ### What is the difference between createElement and cloneElement? JSX elements will be transpiled to `React.createElement()` functions to create React elements which are going to be used for the object representation of UI. Whereas `cloneElement` is used to clone an element and pass it new props. **[⬆ Back to Top](#table-of-contents)** -32. ### What is Lifting State Up in React? +24. ### What is Lifting State Up in React? When several components need to share the same changing data then it is recommended to _lift the shared state up_ to their closest common ancestor. That means if two child components share the same data from its parent, then move the state to parent instead of maintaining local state in both of the child components. **[⬆ Back to Top](#table-of-contents)** -33. ### What are the different phases of component lifecycle? - - The component lifecycle has three distinct lifecycle phases: +25. ### What are Higher-Order Components? - 1. **Mounting:** The component is ready to mount in the browser DOM. This phase covers initialization from `constructor()`, `getDerivedStateFromProps()`, `render()`, and `componentDidMount()` lifecycle methods. + A _higher-order component_ (_HOC_) is a function that takes a component and returns a new component. Basically, it's a pattern that is derived from React's compositional nature. - 2. **Updating:** In this phase, the component gets updated in two ways, sending the new props and updating the state either from `setState()` or `forceUpdate()`. This phase covers `getDerivedStateFromProps()`, `shouldComponentUpdate()`, `render()`, `getSnapshotBeforeUpdate()` and `componentDidUpdate()` lifecycle methods. - - 3. **Unmounting:** In this last phase, the component is not needed and gets unmounted from the browser DOM. This phase includes `componentWillUnmount()` lifecycle method. - - It's worth mentioning that React internally has a concept of phases when applying changes to the DOM. They are separated as follows - - 1. **Render** The component will render without any side effects. This applies to Pure components and in this phase, React can pause, abort, or restart the render. - - 2. **Pre-commit** Before the component actually applies the changes to the DOM, there is a moment that allows React to read from the DOM through the `getSnapshotBeforeUpdate()`. - - 3. **Commit** React works with the DOM and executes the final lifecycles respectively `componentDidMount()` for mounting, `componentDidUpdate()` for updating, and `componentWillUnmount()` for unmounting. - - React 16.3+ Phases (or an [interactive version](http://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/)) - - ![phases 16.4+](images/phases16.4.png) - - Before React 16.3 - - ![phases 16.2](images/phases.png) - - **[⬆ Back to Top](#table-of-contents)** - -34. ### What are the lifecycle methods of React? - - Before React 16.3 - - - **componentWillMount:** Executed before rendering and is used for App level configuration in your root component. - - **componentDidMount:** Executed after first rendering and here all AJAX requests, DOM or state updates, and set up event listeners should occur. - - **componentWillReceiveProps:** Executed when particular prop updates to trigger state transitions. - - **shouldComponentUpdate:** Determines if the component will be updated or not. By default it returns `true`. If you are sure that the component doesn't need to render after state or props are updated, you can return false value. It is a great place to improve performance as it allows you to prevent a re-render if component receives new prop. - - **componentWillUpdate:** Executed before re-rendering the component when there are props & state changes confirmed by `shouldComponentUpdate()` which returns true. - - **componentDidUpdate:** Mostly it is used to update the DOM in response to prop or state changes. - - **componentWillUnmount:** It will be used to cancel any outgoing network requests, or remove all event listeners associated with the component. - - React 16.3+ - - - **getDerivedStateFromProps:** Invoked right before calling `render()` and is invoked on _every_ render. This exists for rare use cases where you need a derived state. Worth reading [if you need derived state](https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html). - - **componentDidMount:** Executed after first rendering and where all AJAX requests, DOM or state updates, and set up event listeners should occur. - - **shouldComponentUpdate:** Determines if the component will be updated or not. By default, it returns `true`. If you are sure that the component doesn't need to render after the state or props are updated, you can return a false value. It is a great place to improve performance as it allows you to prevent a re-render if component receives a new prop. - - **getSnapshotBeforeUpdate:** Executed right before rendered output is committed to the DOM. Any value returned by this will be passed into `componentDidUpdate()`. This is useful to capture information from the DOM i.e. scroll position. - - **componentDidUpdate:** Mostly it is used to update the DOM in response to prop or state changes. This will not fire if `shouldComponentUpdate()` returns `false`. - - **componentWillUnmount** It will be used to cancel any outgoing network requests, or remove all event listeners associated with the component. - - **[⬆ Back to Top](#table-of-contents)** - -35. ### What are Higher-Order Components? - - A _higher-order component_ (_HOC_) is a function that takes a component and returns a new component. Basically, it's a pattern that is derived from React's compositional nature. - - We call them **pure components** because they can accept any dynamically provided child component but they won't modify or copy any behavior from their input components. + We call them **pure components** because they can accept any dynamically provided child component but they won't modify or copy any behavior from their input components. ```javascript const EnhancedComponent = higherOrderComponent(WrappedComponent); @@ -1398,42 +1118,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -36. ### How to create props proxy for HOC component? - - You can add/edit props passed to the component using _props proxy_ pattern like this: - - ```jsx harmony - function HOC(WrappedComponent) { - return class Test extends Component { - render() { - const newProps = { - title: "New Header", - footer: false, - showFeatureX: false, - showFeatureY: true, - }; - - return ; - } - }; - } - ``` - - **[⬆ Back to Top](#table-of-contents)** - -37. ### What is context? - - _Context_ provides a way to pass data through the component tree without having to pass props down manually at every level. - - For example, authenticated users, locale preferences, UI themes need to be accessed in the application by many components. - - ```javascript - const { Provider, Consumer } = React.createContext(defaultValue); - ``` - - **[⬆ Back to Top](#table-of-contents)** - -38. ### What is children prop? +26. ### What is children prop? _Children_ is a prop that allows you to pass components as data to other components, just like any other prop you use. Component tree put between component's opening and closing tag will be passed to that component as `children` prop. @@ -1483,7 +1168,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -39. ### How to write comments in React? +27. ### How to write comments in React? The comments in React/JSX are similar to JavaScript Multiline comments but are wrapped in curly braces. @@ -1508,47 +1193,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -40. ### What is the purpose of using super constructor with props argument? - - A child class constructor cannot make use of `this` reference until the `super()` method has been called. The same applies to ES6 sub-classes as well. The main reason for passing props parameter to `super()` call is to access `this.props` in your child constructors. - - **Passing props:** - - ```javascript - class MyComponent extends React.Component { - constructor(props) { - super(props); - - console.log(this.props); // prints { name: 'John', age: 42 } - } - } - ``` - - **Not passing props:** - - ```javascript - class MyComponent extends React.Component { - constructor(props) { - super(); - - console.log(this.props); // prints undefined - - // but props parameter is still available - console.log(props); // prints { name: 'John', age: 42 } - } - - render() { - // no difference outside constructor - console.log(this.props); // prints { name: 'John', age: 42 } - } - } - ``` - - The above code snippets reveals that `this.props` is different only within the constructor. It would be the same outside the constructor. - - **[⬆ Back to Top](#table-of-contents)** - -41. ### What is reconciliation? +28. ### What is reconciliation? `Reconciliation` is the process through which React updates the Browser DOM and makes React work faster. React use a `diffing algorithm` so that component updates are predictable and faster. React would first calculate the difference between the `real DOM` and the copy of DOM `(Virtual DOM)` when there's an update of components. React stores a copy of Browser DOM which is called `Virtual DOM`. When we make changes or add data, React creates a new Virtual DOM and compares it with the previous one. This comparison is done by `Diffing Algorithm`. @@ -1556,41 +1201,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -42. ### How to set state with a dynamic key name? - - If you are using ES6 or the Babel transpiler to transform your JSX code then you can accomplish this with _computed property names_. - - ```javascript - handleInputChange(event) { - this.setState({ [event.target.id]: event.target.value }) - } - ``` - - **[⬆ Back to Top](#table-of-contents)** - -43. ### What would be the common mistake of function being called every time the component renders? - - You need to make sure that function is not being called while passing the function as a parameter. - - ```jsx harmony - render() { - // Wrong: handleClick is called instead of passed as a reference! - return - } - ``` - - Instead, pass the function itself without parenthesis: - - ```jsx harmony - render() { - // Correct: handleClick is passed as a reference! - return - } - ``` - - **[⬆ Back to Top](#table-of-contents)** - -44. ### Does the lazy function support named exports? +29. ### Does the lazy function support named exports? No, currently `React.lazy` function supports default exports only. If you would like to import modules which are named exports, you can create an intermediate module that reexports it as the default. It also ensures that tree shaking keeps working and don’t pull unused components. Let's take a component file which exports multiple named components, @@ -1617,7 +1228,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -45. ### Why React uses `className` over `class` attribute? +30. ### Why React uses `className` over `class` attribute? The attribute names written in JSX turned into keys of JavaScript objects and the JavaScript names cannot contain dashes or reversed words, it is recommended to use camelCase whereever applicable in JSX code. The attribute `class` is a keyword in JavaScript, and JSX is an extension of JavaScript. That's the principle reason why React uses `className` instead of `class`. Pass a string as the `className` prop. @@ -1629,7 +1240,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -46. ### What are fragments? +31. ### What are fragments? It's a common pattern or practice in React for a component to return multiple elements. _Fragments_ let you group a list of children without adding extra nodes to the DOM. You need to use either **** or a shorter syntax having empty tag (**<>**). @@ -1677,7 +1288,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -47. ### Why fragments are better than container divs? +32. ### Why fragments are better than container divs? Below are the list of reasons to prefer fragments over container DOM elements, @@ -1687,7 +1298,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -48. ### What are portals in React? +33. ### What are portals in React? _Portal_ is a recommended way to render children into a DOM node that exists outside the DOM hierarchy of the parent component. When using CSS transform in a component, its descendant elements should not use fixed positioning, otherwise the layout will blow up. @@ -1700,13 +1311,13 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -50. ### What are stateless components? +34. ### What are stateless components? If the behaviour of a component is independent of its state then it can be a stateless component. You can use either a function or a class for creating stateless components. But unless you need to use a lifecycle hook in your components, you should go for function components. There are a lot of benefits if you decide to use function components here; they are easy to write, understand, and test, a little faster, and you can avoid the `this` keyword altogether. **[⬆ Back to Top](#table-of-contents)** -51. ### What are stateful components? +35. ### What are stateful components? If the behaviour of a component is dependent on the _state_ of the component then it can be termed as stateful component. These _stateful components_ are either function components with hooks or _class components_. @@ -1758,7 +1369,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -52. ### How to apply validation on props in React? +36. ### How to apply validation on props in React? When the application is running in _development mode_, React will automatically check all props that we set on components to make sure they have _correct type_. If the type is incorrect, React will generate warning messages in the console. It's disabled in _production mode_ due to performance impact. The mandatory props are defined with `isRequired`. @@ -1823,7 +1434,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -53. ### What are the advantages of React? +37. ### What are the advantages of React? Below are the list of main advantages of React, @@ -1835,7 +1446,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -54. ### What are the limitations of React? +38. ### What are the limitations of React? Apart from the advantages, there are few limitations of React too, @@ -1847,62 +1458,13 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -55. ### What are error boundaries in React v16? - - _Error boundaries_ are components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of the component tree that crashed. - - A class component becomes an error boundary if it defines a new lifecycle method called `componentDidCatch(error, info)` or `static getDerivedStateFromError() `: - - ```jsx harmony - class ErrorBoundary extends React.Component { - constructor(props) { - super(props); - this.state = { hasError: false }; - } - - componentDidCatch(error, info) { - // You can also log the error to an error reporting service - logErrorToMyService(error, info); - } - - static getDerivedStateFromError(error) { - // Update state so the next render will show the fallback UI. - return { hasError: true }; - } - - render() { - if (this.state.hasError) { - // You can render any custom fallback UI - return

    {"Something went wrong."}

    ; - } - return this.props.children; - } - } - ``` - - After that use it as a regular component: - - ```jsx harmony - - - - ``` - - **[⬆ Back to Top](#table-of-contents)** - -56. ### How are error boundaries handled in React v15? - - React v15 provided very basic support for _error boundaries_ using `unstable_handleError` method. It has been renamed to `componentDidCatch` in React v16. - - **[⬆ Back to Top](#table-of-contents)** - -57. ### What are the recommended ways for static type checking? +39. ### What are the recommended ways for static type checking? Normally we use _PropTypes library_ (`React.PropTypes` moved to a `prop-types` package since React v15.5) for _type checking_ in the React applications. For large code bases, it is recommended to use _static type checkers_ such as Flow or TypeScript, that perform type checking at compile time and provide auto-completion features. **[⬆ Back to Top](#table-of-contents)** -58. ### What is the use of `react-dom` package? +40. ### What is the use of `react-dom` package? The `react-dom` package provides _DOM-specific methods_ that can be used at the top level of your app. Most of the components are not required to use this module. Some of the methods of this package are: @@ -1914,19 +1476,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -59. ### What is the purpose of render method of `react-dom`? - - This method is used to render a React element into the DOM in the supplied container and return a reference to the component. If the React element was previously rendered into container, it will perform an update on it and only mutate the DOM as necessary to reflect the latest changes. - - ``` - ReactDOM.render(element, container, [callback]) - ``` - - If the optional callback is provided, it will be executed after the component is rendered or updated. - - **[⬆ Back to Top](#table-of-contents)** - -60. ### What is ReactDOMServer? +41. ### What is ReactDOMServer? The `ReactDOMServer` object enables you to render components to static markup (typically used on node server). This object is mainly used for _server-side rendering_ (SSR). The following methods can be used in both the server and browser environments: @@ -1953,7 +1503,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -61. ### How to use innerHTML in React? +42. ### How to use innerHTML in React? The `dangerouslySetInnerHTML` attribute is React's replacement for using `innerHTML` in the browser DOM. Just like `innerHTML`, it is risky to use this attribute considering cross-site scripting (XSS) attacks. You just need to pass a `__html` object as key and HTML text as value. @@ -1971,7 +1521,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -62. ### How to use styles in React? +43. ### How to use styles in React? The `style` attribute accepts a JavaScript object with camelCased properties rather than a CSS string. This is consistent with the DOM style JavaScript property, is more efficient, and prevents XSS security holes. @@ -1990,7 +1540,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -63. ### How events are different in React? +44. ### How events are different in React? Handling events in React elements has some syntactic differences: @@ -1999,13 +1549,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -64. ### What will happen if you use `setState()` in constructor? - - When you use `setState()`, then apart from assigning to the object state React also re-renders the component and all its children. You would get error like this: _Can only update a mounted or mounting component._ So we need to use `this.state` to initialize variables inside constructor. - - **[⬆ Back to Top](#table-of-contents)** - -65. ### What is the impact of indexes as keys? +45. ### What is the impact of indexes as keys? Keys should be stable, predictable, and unique so that React can keep track of elements. @@ -2028,102 +1572,42 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -66. ### Is it good to use `setState()` in `componentWillMount()` method? +46. ### How do you conditionally render components? - Yes, it is safe to use `setState()` inside `componentWillMount()` method. But at the same it is recommended to avoid async initialization in `componentWillMount()` lifecycle method. `componentWillMount()` is invoked immediately before mounting occurs. It is called before `render()`, therefore setting state in this method will not trigger a re-render. Avoid introducing any side-effects or subscriptions in this method. We need to make sure async calls for component initialization happened in `componentDidMount()` instead of `componentWillMount()`. + In some cases you want to render different components depending on some state. JSX does not render `false` or `undefined`, so you can use conditional _short-circuiting_ to render a given part of your component only if a certain condition is true. ```jsx harmony - componentDidMount() { - axios.get(`api/todos`) - .then((result) => { - this.setState({ - messages: [...result.data] - }) - }) - } + const MyComponent = ({ name, address }) => ( +
    +

    {name}

    + {address &&

    {address}

    } +
    + ); + ``` + + If you need an `if-else` condition then use _ternary operator_. + + ```jsx harmony + const MyComponent = ({ name, address }) => ( +
    +

    {name}

    + {address ?

    {address}

    :

    {"Address is not available"}

    } +
    + ); ``` **[⬆ Back to Top](#table-of-contents)** -67. ### What will happen if you use props in initial state? +47. ### Why we need to be careful when spreading props on DOM elements? - If the props on the component are changed without the component being refreshed, the new prop value will never be displayed because the constructor function will never update the current state of the component. The initialization of state from props only runs when the component is first created. + When we _spread props_ we run into the risk of adding unknown HTML attributes, which is a bad practice. Instead we can use prop destructuring with `...rest` operator, so it will add only required props. - The below component won't display the updated input value: + For example, ```jsx harmony - class MyComponent extends React.Component { - constructor(props) { - super(props); - - this.state = { - records: [], - inputValue: this.props.inputValue, - }; - } - - render() { - return
    {this.state.inputValue}
    ; - } - } - ``` - - Using props inside render method will update the value: - - ```jsx harmony - class MyComponent extends React.Component { - constructor(props) { - super(props); - - this.state = { - record: [], - }; - } - - render() { - return
    {this.props.inputValue}
    ; - } - } - ``` - - **[⬆ Back to Top](#table-of-contents)** - -68. ### How do you conditionally render components? - - In some cases you want to render different components depending on some state. JSX does not render `false` or `undefined`, so you can use conditional _short-circuiting_ to render a given part of your component only if a certain condition is true. - - ```jsx harmony - const MyComponent = ({ name, address }) => ( -
    -

    {name}

    - {address &&

    {address}

    } -
    - ); - ``` - - If you need an `if-else` condition then use _ternary operator_. - - ```jsx harmony - const MyComponent = ({ name, address }) => ( -
    -

    {name}

    - {address ?

    {address}

    :

    {"Address is not available"}

    } -
    - ); - ``` - - **[⬆ Back to Top](#table-of-contents)** - -69. ### Why we need to be careful when spreading props on DOM elements? - - When we _spread props_ we run into the risk of adding unknown HTML attributes, which is a bad practice. Instead we can use prop destructuring with `...rest` operator, so it will add only required props. - - For example, - - ```jsx harmony - const ComponentA = () => ( - - ); + const ComponentA = () => ( + + ); const ComponentB = ({ isDisplay, ...domProps }) => (
    {"ComponentB"}
    @@ -2132,39 +1616,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -70. ### How you use decorators in React? - - You can _decorate_ your _class_ components, which is the same as passing the component into a function. **Decorators** are flexible and readable way of modifying component functionality. - - ```jsx harmony - @setTitle("Profile") - class Profile extends React.Component { - //.... - } - - /* - title is a string that will be set as a document title - WrappedComponent is what our decorator will receive when - put directly above a component class as seen in the example above - */ - const setTitle = (title) => (WrappedComponent) => { - return class extends React.Component { - componentDidMount() { - document.title = title; - } - - render() { - return ; - } - }; - }; - ``` - - **Note:** Decorators are a feature that didn't make it into ES7, but are currently a _stage 2 proposal_. - - **[⬆ Back to Top](#table-of-contents)** - -71. ### How do you memoize a component? +48. ### How do you memoize a component? There are memoize libraries available which can be used on function components. @@ -2196,7 +1648,7 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -72. ### How you implement Server Side Rendering or SSR? +49. ### How you implement Server Side Rendering or SSR? React is already equipped to handle rendering on Node servers. A special version of the DOM renderer is available, which follows the same pattern as on the client side. @@ -2211,5649 +1663,6294 @@ Hide/Show table of contents **[⬆ Back to Top](#table-of-contents)** -73. ### How to enable production mode in React? +50. ### How to enable production mode in React? You should use Webpack's `DefinePlugin` method to set `NODE_ENV` to `production`, by which it strip out things like propType validation and extra warnings. Apart from this, if you minify the code, for example, Uglify's dead-code elimination to strip out development only code and comments, it will drastically reduce the size of your bundle. **[⬆ Back to Top](#table-of-contents)** -74. ### What is CRA and its benefits? +51. ### Do Hooks replace render props and higher order components? - The `create-react-app` CLI tool allows you to quickly create & run React applications with no configuration step. - - Let's create Todo App using _CRA_: + Both render props and higher-order components render only a single child but in most of the cases Hooks are a simpler way to serve this by reducing nesting in your tree. - ```console - # Installation - $ npm install -g create-react-app + **[⬆ Back to Top](#table-of-contents)** - # Create new project - $ create-react-app todo-app - $ cd todo-app +52. ### What is a switching component? - # Build, test and run - $ npm run build - $ npm run test - $ npm start - ``` + A _switching component_ is a component that renders one of many components. We need to use object to map prop values to components. - It includes everything we need to build a React app: + For example, a switching component to display different pages based on `page` prop: - 1. React, JSX, ES6, and Flow syntax support. - 2. Language extras beyond ES6 like the object spread operator. - 3. Autoprefixed CSS, so you don’t need -webkit- or other prefixes. - 4. A fast interactive unit test runner with built-in support for coverage reporting. - 5. A live development server that warns about common mistakes. - 6. A build script to bundle JS, CSS, and images for production, with hashes and sourcemaps. + ```jsx harmony + import HomePage from "./HomePage"; + import AboutPage from "./AboutPage"; + import ServicesPage from "./ServicesPage"; + import ContactPage from "./ContactPage"; - **[⬆ Back to Top](#table-of-contents)** + const PAGES = { + home: HomePage, + about: AboutPage, + services: ServicesPage, + contact: ContactPage, + }; -75. ### What is the lifecycle methods order in mounting? + const Page = (props) => { + const Handler = PAGES[props.page] || ContactPage; - The lifecycle methods are called in the following order when an instance of a component is being created and inserted into the DOM. + return ; + }; - 1. `constructor()` - 2. `static getDerivedStateFromProps()` - 3. `render()` - 4. `componentDidMount()` + // The keys of the PAGES object can be used in the prop types to catch dev-time errors. + Page.propTypes = { + page: PropTypes.oneOf(Object.keys(PAGES)).isRequired, + }; + ``` **[⬆ Back to Top](#table-of-contents)** -76. ### What are the lifecycle methods going to be deprecated in React v16? +53. ### What are React Mixins? - The following lifecycle methods going to be unsafe coding practices and will be more problematic with async rendering. + _Mixins_ are a way to totally separate components to have a common functionality. Mixins **should not be used** and can be replaced with _higher-order components_ or _decorators_. - 1. `componentWillMount()` - 2. `componentWillReceiveProps()` - 3. `componentWillUpdate()` + One of the most commonly used mixins is `PureRenderMixin`. You might be using it in some components to prevent unnecessary re-renders when the props and state are shallowly equal to the previous props and state: - Starting with React v16.3 these methods are aliased with `UNSAFE_` prefix, and the unprefixed version will be removed in React v17. + ```javascript + const PureRenderMixin = require("react-addons-pure-render-mixin"); + + const Button = React.createClass({ + mixins: [PureRenderMixin], + // ... + }); + ``` + + **[⬆ Back to Top](#table-of-contents)** -77. ### What is the purpose of `getDerivedStateFromProps()` lifecycle method? +54. ### What are the Pointer Events supported in React? - The new static `getDerivedStateFromProps()` lifecycle method is invoked after a component is instantiated as well as before it is re-rendered. It can return an object to update state, or `null` to indicate that the new props do not require any state updates. + _Pointer Events_ provide a unified way of handling all input events. In the old days we had a mouse and respective event listeners to handle them but nowadays we have many devices which don't correlate to having a mouse, like phones with touch surface or pens. We need to remember that these events will only work in browsers that support the _Pointer Events_ specification. - ```javascript - class MyComponent extends React.Component { - static getDerivedStateFromProps(props, state) { - // ... - } - } - ``` + The following event types are now available in _React DOM_: - This lifecycle method along with `componentDidUpdate()` covers all the use cases of `componentWillReceiveProps()`. + 1. `onPointerDown` + 2. `onPointerMove` + 3. `onPointerUp` + 4. `onPointerCancel` + 5. `onGotPointerCapture` + 6. `onLostPointerCapture` + 7. `onPointerEnter` + 8. `onPointerLeave` + 9. `onPointerOver` + 10. `onPointerOut` **[⬆ Back to Top](#table-of-contents)** -78. ### What is the purpose of `getSnapshotBeforeUpdate()` lifecycle method? +55. ### Why should component names start with capital letter? - The new `getSnapshotBeforeUpdate()` lifecycle method is called right before DOM updates. The return value from this method will be passed as the third parameter to `componentDidUpdate()`. + If you are rendering your component using JSX, the name of that component has to begin with a capital letter otherwise React will throw an error as an unrecognized tag. This convention is because only HTML elements and SVG tags can begin with a lowercase letter. - ```javascript - class MyComponent extends React.Component { - getSnapshotBeforeUpdate(prevProps, prevState) { - // ... - } + ```jsx harmony + function SomeComponent { + // Code goes here } ``` - This lifecycle method along with `componentDidUpdate()` covers all the use cases of `componentWillUpdate()`. + You can define function component which name starts with lowercase letter, but when it's imported it should have capital letter. Here lowercase is fine: - **[⬆ Back to Top](#table-of-contents)** + ```jsx harmony + function myComponent { + render() { + return
    ; + } + } -79. ### Do Hooks replace render props and higher order components? + export default myComponent; + ``` - Both render props and higher-order components render only a single child but in most of the cases Hooks are a simpler way to serve this by reducing nesting in your tree. + While when imported in another file it should start with capital letter: + + ```jsx harmony + import MyComponent from "./myComponent"; + ``` **[⬆ Back to Top](#table-of-contents)** -80. ### What is the recommended way for naming components? +56. ### Are custom DOM attributes supported in React v16? - It is recommended to name the component by reference instead of using `displayName`. + Yes. In the past, React used to ignore unknown DOM attributes. If you wrote JSX with an attribute that React doesn't recognize, React would just skip it. - Using `displayName` for naming component: + For example, let's take a look at the below attribute: - ```javascript - export default React.createClass({ - displayName: "TodoApp", - // ... - }); + ```jsx harmony +
    ``` - The **recommended** approach: + Would render an empty div to the DOM with React v15: - ```javascript - export default class TodoApp extends React.Component { - // ... - } + ```html +
    ``` - also + In React v16 any unknown attributes will end up in the DOM: - ```javascript - const TodoApp = () => { - //... - }; - export default TodoApp; + ```html +
    ``` + This is useful for supplying browser-specific non-standard attributes, trying new DOM APIs, and integrating with opinionated third-party libraries. + **[⬆ Back to Top](#table-of-contents)** -81. ### What is the recommended ordering of methods in component class? +57. ### How to loop inside JSX? - _Recommended_ ordering of methods from _mounting_ to _render stage_: + You can simply use `Array.prototype.map` with ES6 _arrow function_ syntax. - 1. `static` methods - 2. `constructor()` - 3. `getChildContext()` - 4. `componentWillMount()` - 5. `componentDidMount()` - 6. `componentWillReceiveProps()` - 7. `shouldComponentUpdate()` - 8. `componentWillUpdate()` - 9. `componentDidUpdate()` - 10. `componentWillUnmount()` - 11. click handlers or event handlers like `onClickSubmit()` or `onChangeDescription()` - 12. getter methods for render like `getSelectReason()` or `getFooterContent()` - 13. optional render methods like `renderNavigation()` or `renderProfilePicture()` - 14. `render()` - - **[⬆ Back to Top](#table-of-contents)** - -82. ### What is a switching component? - - A _switching component_ is a component that renders one of many components. We need to use object to map prop values to components. - - For example, a switching component to display different pages based on `page` prop: + For example, the `items` array of objects is mapped into an array of components: ```jsx harmony - import HomePage from "./HomePage"; - import AboutPage from "./AboutPage"; - import ServicesPage from "./ServicesPage"; - import ContactPage from "./ContactPage"; - - const PAGES = { - home: HomePage, - about: AboutPage, - services: ServicesPage, - contact: ContactPage, - }; - - const Page = (props) => { - const Handler = PAGES[props.page] || ContactPage; + + {items.map((item) => ( + + ))} + + ``` - return ; - }; + But you can't iterate using `for` loop: - // The keys of the PAGES object can be used in the prop types to catch dev-time errors. - Page.propTypes = { - page: PropTypes.oneOf(Object.keys(PAGES)).isRequired, - }; + ```jsx harmony + + for (let i = 0; i < items.length; i++) { + + } + ``` - **[⬆ Back to Top](#table-of-contents)** + This is because JSX tags are transpiled into _function calls_, and you can't use statements inside expressions. This may change thanks to `do` expressions which are _stage 1 proposal_. -83. ### Why we need to pass a function to setState()? + **[⬆ Back to Top](#table-of-contents)** - The reason behind for this is that `setState()` is an asynchronous operation. React batches state changes for performance reasons, so the state may not change immediately after `setState()` is called. That means you should not rely on the current state when calling `setState()` since you can't be sure what that state will be. The solution is to pass a function to `setState()`, with the previous state as an argument. By doing this you can avoid issues with the user getting the old state value on access due to the asynchronous nature of `setState()`. +58. ### How do you access props in attribute quotes? - Let's say the initial count value is zero. After three consecutive increment operations, the value is going to be incremented only by one. + React (or JSX) doesn't support variable interpolation inside an attribute value. The below representation won't work: - ```javascript - // assuming this.state.count === 0 - this.setState({ count: this.state.count + 1 }); - this.setState({ count: this.state.count + 1 }); - this.setState({ count: this.state.count + 1 }); - // this.state.count === 1, not 3 + ```jsx harmony + ``` - If we pass a function to `setState()`, the count gets incremented correctly. + But you can put any JS expression inside curly braces as the entire attribute value. So the below expression works: - ```javascript - this.setState((prevState, props) => ({ - count: prevState.count + props.increment, - })); - // this.state.count === 3 as expected + ```jsx harmony + ``` - **(OR)** - - ### Why function is preferred over object for `setState()`? + Using _template strings_ will also work: - React may batch multiple `setState()` calls into a single update for performance. Because `this.props` and `this.state` may be updated asynchronously, you should not rely on their values for calculating the next state. + ```jsx harmony + + ``` - This counter example will fail to update as expected: + **[⬆ Back to Top](#table-of-contents)** - ```javascript - // Wrong - this.setState({ - counter: this.state.counter + this.props.increment, - }); - ``` +59. ### What is React proptype array with shape? - The preferred approach is to call `setState()` with function rather than object. That function will receive the previous state as the first argument, and the props at the time the update is applied as the second argument. + If you want to pass an array of objects to a component with a particular shape then use `React.PropTypes.shape()` as an argument to `React.PropTypes.arrayOf()`. ```javascript - // Correct - this.setState((prevState, props) => ({ - counter: prevState.counter + props.increment, - })); + ReactComponent.propTypes = { + arrayWithShape: React.PropTypes.arrayOf( + React.PropTypes.shape({ + color: React.PropTypes.string.isRequired, + fontSize: React.PropTypes.number.isRequired, + }) + ).isRequired, + }; ``` **[⬆ Back to Top](#table-of-contents)** -84. ### What are React Mixins? - - _Mixins_ are a way to totally separate components to have a common functionality. Mixins **should not be used** and can be replaced with _higher-order components_ or _decorators_. - - One of the most commonly used mixins is `PureRenderMixin`. You might be using it in some components to prevent unnecessary re-renders when the props and state are shallowly equal to the previous props and state: +60. ### How to conditionally apply class attributes? - ```javascript - const PureRenderMixin = require("react-addons-pure-render-mixin"); + You shouldn't use curly braces inside quotes because it is going to be evaluated as a string. - const Button = React.createClass({ - mixins: [PureRenderMixin], - // ... - }); + ```jsx harmony +
    ``` - - - **[⬆ Back to Top](#table-of-contents)** + Instead you need to move curly braces outside (don't forget to include spaces between class names): -85. ### Why is `isMounted()` an anti-pattern and what is the proper solution? + ```jsx harmony +
    + ``` - The primary use case for `isMounted()` is to avoid calling `setState()` after a component has been unmounted, because it will emit a warning. + _Template strings_ will also work: - ```javascript - if (this.isMounted()) { - this.setState({...}) - } + ```jsx harmony +
    ``` - Checking `isMounted()` before calling `setState()` does eliminate the warning, but it also defeats the purpose of the warning. Using `isMounted()` is a code smell because the only reason you would check is because you think you might be holding a reference after the component has unmounted. + **[⬆ Back to Top](#table-of-contents)** - An optimal solution would be to find places where `setState()` might be called after a component has unmounted, and fix them. Such situations most commonly occur due to callbacks, when a component is waiting for some data and gets unmounted before the data arrives. Ideally, any callbacks should be canceled in `componentWillUnmount()`, prior to unmounting. +61. ### What is the difference between React and ReactDOM? - **[⬆ Back to Top](#table-of-contents)** + The `react` package contains `React.createElement()`, `React.Component`, `React.Children`, and other helpers related to elements and component classes. You can think of these as the isomorphic or universal helpers that you need to build components. The `react-dom` package contains `ReactDOM.render()`, and in `react-dom/server` we have _server-side rendering_ support with `ReactDOMServer.renderToString()` and `ReactDOMServer.renderToStaticMarkup()`. -86. ### What are the Pointer Events supported in React? + **[⬆ Back to Top](#table-of-contents)** - _Pointer Events_ provide a unified way of handling all input events. In the old days we had a mouse and respective event listeners to handle them but nowadays we have many devices which don't correlate to having a mouse, like phones with touch surface or pens. We need to remember that these events will only work in browsers that support the _Pointer Events_ specification. +62. ### Why ReactDOM is separated from React? - The following event types are now available in _React DOM_: + The React team worked on extracting all DOM-related features into a separate library called _ReactDOM_. React v0.14 is the first release in which the libraries are split. By looking at some of the packages, `react-native`, `react-art`, `react-canvas`, and `react-three`, it has become clear that the beauty and essence of React has nothing to do with browsers or the DOM. - 1. `onPointerDown` - 2. `onPointerMove` - 3. `onPointerUp` - 4. `onPointerCancel` - 5. `onGotPointerCapture` - 6. `onLostPointerCapture` - 7. `onPointerEnter` - 8. `onPointerLeave` - 9. `onPointerOver` - 10. `onPointerOut` + To build more environments that React can render to, React team planned to split the main React package into two: `react` and `react-dom`. This paves the way to writing components that can be shared between the web version of React and React Native. **[⬆ Back to Top](#table-of-contents)** -87. ### Why should component names start with capital letter? +63. ### How to use React label element? - If you are rendering your component using JSX, the name of that component has to begin with a capital letter otherwise React will throw an error as an unrecognized tag. This convention is because only HTML elements and SVG tags can begin with a lowercase letter. + If you try to render a `