Skip to content

[pull] master from sudheerj:master #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 218 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
218 commits
Select commit Hold shift + click to select a range
3f93d77
Add codingninja collab
sudheerj Dec 10, 2022
8f962f2
Update collab
sudheerj Dec 12, 2022
4e591dc
Update format for class over function component
sudheerj Dec 12, 2022
8b1d463
Updated state question with function component
sudheerj Dec 12, 2022
8d255cd
Update collab
sudheerj Dec 15, 2022
50e25c8
Update major features of React
Dec 26, 2022
d12292e
Update codeblock
phongever Jan 3, 2023
e0181a5
Merge pull request #210 from HarukiNguyen/master
sudheerj Jan 7, 2023
efb38a1
Merge pull request #213 from phongever/master
sudheerj Jan 7, 2023
4443587
Update the Navigation link
harshal015 Jan 7, 2023
d04109e
Merge pull request #215 from Harshal2502/branch1
sudheerj Jan 8, 2023
fdc119f
fix: question 7 typo
mbinou Jan 8, 2023
2d82219
fix: question 198 typo
mbinou Jan 8, 2023
636d4d3
fix: question 332 typo
mbinou Jan 8, 2023
540ebee
Merge pull request #216 from mbinou/fix-typo
sudheerj Jan 8, 2023
97f8685
Update question #104 answer
elyesbenabdelkader Jan 10, 2023
c6bf3fb
Merge pull request #218 from elyesbenabdelkader/update_question_104_a…
sudheerj Jan 11, 2023
0649d46
Remove this in functional component
sudheerj Jan 23, 2023
acb8ac1
new questions #333 and #334 added
Jan 24, 2023
8645ecf
Merge pull request #223 from gurjar-sumitu4500/gurjar-sumitu4500/master
sudheerj Jan 25, 2023
bf989f1
Remove github actions documentation
sudheerj Jan 29, 2023
b1875d8
Update answer to question 303
adrian-burkhart Feb 3, 2023
bbb2a8a
Update README.md
theteladras Feb 4, 2023
c254697
Merge pull request #225 from theteladras/patch-1
sudheerj Feb 4, 2023
cd0e5ef
Updated functional and class component differences
sudheerj Feb 9, 2023
b04cedc
Merge pull request #224 from adrian-burkhart/master
sudheerj Feb 10, 2023
bd15946
Update README.md
aduyng Feb 16, 2023
1f5102e
Update README.md
aduyng Feb 16, 2023
4f98594
Merge pull request #227 from aduyng/master
sudheerj Feb 17, 2023
fe9560a
Added easy Explanation in Question 10
chetannada Mar 5, 2023
2ef84c9
Merge pull request #233 from chetannada/Question-10
sudheerj Mar 7, 2023
f8c947b
Add question related to duplicated render
sudheerj Mar 7, 2023
11994e1
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj Mar 7, 2023
c079c43
Fixed format issue
sudheerj Mar 8, 2023
56baef4
Update jsx questio
sudheerj Mar 9, 2023
7644e2d
Update JSX and state questions
sudheerj Mar 10, 2023
cb5e043
added functional component example to the question no.100, the class …
Shahidullah-Muffakir Mar 13, 2023
bd75016
Update state question
sudheerj Mar 13, 2023
68b430f
Merge pull request #236 from Shahidullah-Muffakir/refactor/class-to-f…
sudheerj Mar 14, 2023
da8548e
Update event questions
sudheerj Mar 18, 2023
b593449
Add react history question and update stateful component
sudheerj Mar 19, 2023
e64b0c9
Add coding questions
sudheerj Mar 25, 2023
98b6610
Update key attribute question
sudheerj Mar 26, 2023
b75591b
Improve react introduction questions
sudheerj Mar 26, 2023
3d46811
Replace html tags with markdown tags
martinschneider01 Mar 27, 2023
dfbb5f6
Update README.md
martinschneider01 Mar 27, 2023
4155780
Fix some styling issues in q335 and q336
martinschneider01 Mar 27, 2023
116fe4e
Fix indent of Back To Top links
martinschneider01 Mar 27, 2023
98917d9
Update questions related to components
sudheerj Mar 27, 2023
4a22bc1
Merge pull request #240 from martinschneider01/master
sudheerj Mar 27, 2023
3c03468
Improve react fundamental questions
sudheerj Mar 31, 2023
a5cfd3c
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj Mar 31, 2023
ab2e839
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj Mar 31, 2023
70c0c38
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj Mar 31, 2023
4b91fc1
Update hooks question description and rules
sudheerj Apr 4, 2023
bd93582
Added easy and meaningful Answer of Reconciliation Process
chetannada Apr 7, 2023
d352487
Fixing the duplicated word in question #10
HenriqueMarcelo Apr 10, 2023
f27613e
fixing tab issue to have code and text separately
MidhaTahir Apr 10, 2023
7ed5bfa
Merge pull request #245 from HenriqueMarcelo/master
sudheerj Apr 10, 2023
71eda3c
Merge pull request #246 from MidhaTahir/master
sudheerj Apr 10, 2023
1c7d6a9
Merge pull request #243 from chetannada/Question41
sudheerj Apr 12, 2023
010b1b6
Added React import
sudheerj Apr 12, 2023
7932c58
correcting example of using <Fragment>
HenriqueMarcelo Apr 12, 2023
3518b5f
Coding exercise for ref usage
sudheerj Apr 16, 2023
24b758a
Merge pull request #249 from HenriqueMarcelo/master
sudheerj Apr 16, 2023
0f4c40d
Update answers of hook rules and linting
sudheerj Apr 18, 2023
2484dfe
Update App.js
abhay502 Apr 20, 2023
5b24cd3
Merge pull request #251 from abhay502/patch-1
sudheerj Apr 20, 2023
0057256
Detailed Answer added with example in Question 218
chetannada May 24, 2023
0e2b84a
Update README.md
alivarastepour Jul 26, 2023
69c1c3c
Merge pull request #265 from alivarastepour/patch-1
sudheerj Jul 27, 2023
a4901aa
Reorder strict mode
sudheerj Sep 16, 2023
09c9b9f
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj Sep 16, 2023
f840de7
Add uidev sponsor
sudheerj Sep 16, 2023
86cfb39
Fix update state for Q335
sudheerj Sep 17, 2023
0bd6a46
Update README.md
tylermcginnis Sep 17, 2023
5b7a5a4
Merge pull request #272 from tylermcginnis/patch-1
sudheerj Sep 17, 2023
f4722e7
Quetion 3 : coding typo
savaliya-007 Oct 7, 2023
e6cb1ac
Merge pull request #275 from Umesh-WW/patch-1
sudheerj Oct 7, 2023
ad55d7d
Answer for Q4 : Apply JavaScript syntax highlighting to code block
mrAJAY1 Dec 15, 2023
b1c778b
Merge pull request #286 from mrAJAY1/patch-1
sudheerj Dec 16, 2023
53a06ab
Added a note about using react-error-boundary in client components to…
mrAJAY1 Dec 16, 2023
06cd3de
fix(typo): corrected the spelling of principle according to the conte…
Dec 25, 2023
459dff4
Merge pull request #289 from veekays/fix-typo
sudheerj Dec 27, 2023
afb8a2d
Merge pull request #288 from mrAJAY1/patch-2
sudheerj Jan 1, 2024
d5df7be
Q.7 changed "use client" inside note to code block.
mrAJAY1 Jan 1, 2024
19d335b
Update README.md
npiyush97 Jan 2, 2024
a926f16
Merge pull request #291 from npiyush97/npiyush97-patch-2
sudheerj Jan 2, 2024
52709ad
Merge pull request #290 from mrAJAY1/patch-3
sudheerj Jan 2, 2024
a08b3fe
Explain the reason for using React.portal
MarufZak Jan 24, 2024
f84dcf6
Update README.md
RutujaJotrao Jan 31, 2024
ae7e8b7
Update README.md
npiyush97 Feb 2, 2024
b0c0181
Merge pull request #298 from npiyush97/npiyush97-patch-2
sudheerj Feb 4, 2024
f4025d0
Merge pull request #296 from RutujaJotrao/patch-1
sudheerj Feb 4, 2024
7860daf
Updated answer to when to use functional vs class components. made th…
v-athithyaramaa Feb 27, 2024
97997b5
fix(spacing): add missing space before parenthesis
michelegera Mar 3, 2024
9a49e81
Merge pull request #302 from michelegera/fix-space
sudheerj Mar 4, 2024
c35d03c
feat: Update statement to reflect availability of React.lazy and Susp…
sayinmehmet47 Mar 8, 2024
2e04435
Merge pull request #303 from sayinmehmet47/feature/react-18-loader-ch…
sudheerj Mar 9, 2024
b646bd6
Refactor existing questions and new questions about JSX
sudheerj Mar 30, 2024
69ec0ae
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj Mar 30, 2024
9d1e4cf
Merge pull request #301 from athithyaramaa1/patch-1
sudheerj Mar 31, 2024
409217c
Merge pull request #294 from MarufZak/master
sudheerj Mar 31, 2024
18826d2
Fix formatting issues
sudheerj Mar 31, 2024
55f906e
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj Mar 31, 2024
03741ca
Merge pull request #255 from chetannada/question218-fix
sudheerj Apr 1, 2024
4676ac5
Add hooks and strict mode concepts
sudheerj Apr 2, 2024
5103af9
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj Apr 2, 2024
608d6bf
Add TOC toggle, update state and props questions
sudheerj Apr 2, 2024
b48a8c9
Add state updates and hydration questions
sudheerj Apr 2, 2024
51ddbbb
Add state update questions
sudheerj Apr 3, 2024
73ee8ba
Add immer for object updates
sudheerj Apr 4, 2024
ff6b0e0
Update controlled and uncontrolled components
sudheerj Apr 6, 2024
4900301
Re-organized with new and old questions
sudheerj Apr 13, 2024
b3bfd6b
Update typescript create react app answer
sudheerj May 29, 2024
3a87323
fix stopPropagation typo
mhsiungw Jun 2, 2024
f61d2e2
Merge pull request #310 from mhsiungw/master
sudheerj Jun 2, 2024
e127833
Update Question 55 README.md
Benappiahpoku Jun 2, 2024
a5af24a
Merge pull request #311 from Benappiahpoku/patch-1
sudheerj Jun 5, 2024
b09ba28
Update Question 81 to React Router V6 README.md
Benappiahpoku Jun 10, 2024
d3063e5
Merge pull request #314 from Benappiahpoku/patch-2
sudheerj Jun 10, 2024
d7e5b27
Update 129 TOC and Question README.md
Benappiahpoku Jun 12, 2024
601c5b8
Update Question 140 README.md
Benappiahpoku Jun 12, 2024
2e4de79
Merge pull request #316 from Benappiahpoku/patch-4
sudheerj Jun 12, 2024
5ac2078
Merge pull request #317 from Benappiahpoku/patch-5
sudheerj Jun 12, 2024
f34161d
Update Question 162 README.md
Benappiahpoku Jun 13, 2024
26dd3d4
Update 174 TOC and Question README.md
Benappiahpoku Jun 13, 2024
c9c78fb
Merge pull request #318 from Benappiahpoku/patch-6
sudheerj Jun 13, 2024
198c392
Merge pull request #319 from Benappiahpoku/patch-7
sudheerj Jun 13, 2024
39d32a6
Add GreatFrontEnd banner
yangshun Jun 13, 2024
61759a6
Merge pull request #320 from yangshun/master
sudheerj Jun 13, 2024
eb4acbf
Update GFE banner URL
yangshun Jun 19, 2024
e68591b
Merge pull request #322 from yangshun/patch-1
sudheerj Jun 19, 2024
b324eab
Add client and server components usecases
sudheerj Jun 23, 2024
97931d1
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj Jun 23, 2024
8f384b8
Update README.md
suryakantkasare Jun 29, 2024
bc6d6a7
Merge pull request #323 from surykantkasare/patch-1
sudheerj Jun 30, 2024
e6624d4
Update README.md
yangshun Jun 30, 2024
ebd3552
Merge pull request #324 from yangshun/patch-2
sudheerj Jul 5, 2024
c967efb
Update README.md
Manojbachhal Jul 5, 2024
1b67f8d
Merge pull request #325 from Manojbachhal/patch-1
sudheerj Jul 6, 2024
e497993
Question 31: fix <Fragment> being treated as html tag
subhoghoshX Jul 11, 2024
dd49f46
Question 65: fix code block rendering
subhoghoshX Jul 11, 2024
65cbb9b
Question 73: use consistent heading level
subhoghoshX Jul 11, 2024
940477f
Merge pull request #326 from subhoghoshX/fixes
sudheerj Jul 24, 2024
a37debf
add code syntax to Fragment, delete redundant word
oscartorres-10 Jul 24, 2024
6c929bf
refactor(case): use camelCase in "TypeScript" and "ReactJS"
oscartorres-10 Jul 25, 2024
10f8557
refactor(case): add upper case for "JS" in "ReactJS"
oscartorres-10 Jul 25, 2024
8d1b5eb
fix(Question 244): fix typos
oscartorres-10 Jul 25, 2024
0521adb
fix(Question 244): fix typos, remove redundant words
oscartorres-10 Jul 25, 2024
301d502
fix(Question 244): fix typos, remove redundant words
oscartorres-10 Jul 25, 2024
746e675
Merge pull request #330 from oscartorres-10/patch-3
sudheerj Jul 25, 2024
ca52c61
Merge pull request #329 from oscartorres-10/patch-2
sudheerj Jul 25, 2024
b738c40
Merge pull request #328 from oscartorres-10/patch-1
sudheerj Jul 26, 2024
8110c96
Minor styling and content improvements
sudheerj Aug 4, 2024
66254e2
Update default values question
sudheerj Aug 13, 2024
15dc072
Fix typos
szepeviktor Aug 13, 2024
d2ea5a7
Merge pull request #335 from szepeviktor/typos
sudheerj Aug 13, 2024
d234c64
Fix code alignment issues
sudheerj Aug 18, 2024
0e99671
Fix formatting issue
sudheerj Aug 23, 2024
f4f9f06
Add useContext hook usecases
sudheerj Aug 27, 2024
942666f
Add license
sudheerj Sep 18, 2024
33b8aa9
Create FUNDING.yml
sudheerj Sep 18, 2024
5e76a21
Update FUNDING.yml
sudheerj Sep 18, 2024
eee0084
Fix typo
in-in Nov 4, 2024
4e12c89
Merge pull request #342 from in-in/patch-1
sudheerj Nov 4, 2024
78d92da
Update README.md
naazeri Dec 21, 2024
dc34667
format text
naazeri Dec 21, 2024
ad252cd
Merge pull request #345 from naazeri/master
sudheerj Dec 22, 2024
6d02614
Add examples for hooks rules
sudheerj Feb 24, 2025
0e23cd5
Add examples for hooks rules
sudheerj Feb 24, 2025
3e906f6
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj Feb 24, 2025
dd6de7a
Update README.md
sharjeelfaiq Feb 24, 2025
42f27d5
Merge pull request #348 from sharjeelfaiq/patch-1
sudheerj Feb 24, 2025
67d36c8
Doc: Fix grammatical inconsistencies
waiz3ple Mar 3, 2025
7d49b5a
Update ESLint for hooks
sudheerj Mar 7, 2025
8bcce8c
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj Mar 7, 2025
75a5ee9
Resolved merge conflicts
waiz3ple Mar 29, 2025
554a426
update catches
waiz3ple Mar 29, 2025
59e17c1
update catches
waiz3ple Mar 29, 2025
8eb4b01
Merge pull request #349 from waiz3ple/grammar-fix
sudheerj Mar 31, 2025
cd00835
docs: update subtitle #67 to match content
kenshanta Apr 9, 2025
504cd69
Updated the README.md with some grammatical mistakes
DHRUVKUMARMAHESHWARI Apr 21, 2025
9db4d53
Merge pull request #354 from DHRUVKUMARMAHESHWARI/patch-1
sudheerj May 13, 2025
996dc37
Merge pull request #352 from kenshanta/fix-67-subtitle-typo
sudheerj May 13, 2025
0aaec79
Improve element and component answer
sudheerj May 18, 2025
f7c4705
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj May 18, 2025
f1dd846
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj May 18, 2025
7cd44ff
Merge branch 'master' of https://github.com/sudheerj/reactjs-intervie…
sudheerj May 18, 2025
17d1913
Update state & prop difference for better clarity
sudheerj May 18, 2025
c7e2a02
Modify setState callback answer
sudheerj May 19, 2025
29f9cc0
Update async/await usage answer in React
sudheerj May 19, 2025
b705b33
Added useMemo hook question
sudheerj May 19, 2025
29a83fc
Enhance introductory questions of React
sudheerj May 22, 2025
e2be989
Format react history deep dive
sudheerj Jun 13, 2025
a4f162c
Add useState questions
sudheerj Jun 14, 2025
dc2e82c
Add useState internal implementation
sudheerj Jun 14, 2025
1c0ac5b
Add useHook and its usage question
sudheerj Jun 15, 2025
dd22bae
How React works and hooks questions
sudheerj Jun 15, 2025
ceea6c0
Add useReducer questions
sudheerj Jun 15, 2025
ac72597
Dispatch multiple actions
sudheerj Jun 16, 2025
9493350
Add useContext questions
sudheerj Jun 16, 2025
e12c600
Add advanced questions related to useContext hook
sudheerj Jun 16, 2025
bd14a88
Fix formatting related to folder structure query
sudheerj Jun 16, 2025
b762ba6
Add advanced useEffect hooks
sudheerj Jun 16, 2025
efb9974
Improved controlled and uncontrolled components
sudheerj Jun 17, 2025
12655d8
Add useLayoutEffect questions
sudheerj Jun 17, 2025
da5c520
Add useMemo hook questions
sudheerj Jun 19, 2025
6bd02b2
Add useCallback question
sudheerj Jun 19, 2025
b6a8ff2
Add custom hook questions
sudheerj Jun 20, 2025
2b9f8d5
Add redux questions
sudheerj Jun 20, 2025
456e615
Update React core concepts
sudheerj Jun 21, 2025
2b1848f
Modifying react basic questions
sudheerj Jun 21, 2025
b8b12ee
Improve portals questions
sudheerj Jun 22, 2025
e53776a
Update suspense feature
sudheerj Jun 22, 2025
da89975
Improve redux vs flux
sudheerj Jun 28, 2025
8a0bb48
Update banner area
sudheerj Jul 8, 2025
4e89b3d
Update banner section
sudheerj Jul 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These are supported funding model platforms

github: [sudheerj]
custom: https://buymeacoffee.com/sudheerj

34 changes: 0 additions & 34 deletions .github/workflows/main.yaml

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017-Present Sudheer Jonna

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9,855 changes: 9,855 additions & 0 deletions README.md

Large diffs are not rendered by default.

235 changes: 198 additions & 37 deletions coding-exercise/README.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,229 @@
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 (
<>
<span>{counter}</span>
<button onClick={() => {
setCounter(counter + 5);
setCounter(counter + 5);
alert(counter);
setCounter(counter + 5);
setCounter(counter + 5);
}}>Increment</button>
</>
)
}
```

- 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

<details><summary><b>Answer</b></summary>
<p>

##### 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 until all the code executed with in an event handler before your state updates followed 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
<button onClick={() => {
setCounter(5 + 5);
setCounter(5 + 5);
alert(5);
setCounter(5 + 5);
setCounter(5 + 5);
}}>Increment</button>
```
</p>
</details>

In the project directory, you can run:
---

### `yarn start`
**[⬆ Back to Top](#table-of-contents)**

Runs the app in the development mode.<br />
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.<br />
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 (
<>
<span>{counter}</span>
<button onClick={() => {
setCounter(counter => counter + 5);
setCounter(counter => counter + 5);
alert(counter);
setCounter(counter => counter + 5);
setCounter(counter => counter + 5);
}}>Increment</button>
</>
)
}
```

- 1: Alert with 5, 25
- 2: Alert with 5, 10
- 3: Alert with 15, 25
- 4: Alert with 15, 10

<details><summary><b>Answer</b></summary>
<p>

##### Answer: 1

Launches the test runner in the interactive watch mode.<br />
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`
</p>
</details>

Builds the app for production to the `build` folder.<br />
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.<br />
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
<>
<span>Count: {countRef.current}</span>
<button onClick={handleIncrement}>
Click me
</button>
</>
}
```

- 1: Cannot read current property of undefined
- 2: Count: 1
- 3: null
- 4: Count: 0

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.
<details><summary><b>Answer</b></summary>
<p>

## Learn More
##### Answer: 4

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
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

To learn React, check out the [React documentation](https://reactjs.org/).
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.
</p>
</details>

### Code Splitting
---

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
**[⬆ Back to Top](#table-of-contents)**

### Analyzing the Bundle Size
#### 4. What is the outcome of below code after button click?

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
```javascript
import { useRef } from 'react';

### Making a Progressive Web App
function MyCustomInput(props) {
return <input {...props} />;
}

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
export default function MyCustomForm() {
const inputRef = useRef(null);

### Advanced Configuration
function handleInputFocus() {
inputRef.current.focus();
}

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
return (
<>
<MyCustomInput ref={inputRef} />
<button onClick={handleInputFocus}>
Click Me
</button>
</>
);
}
```

### 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 <input /> element

This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
<details><summary><b>Answer</b></summary>
<p>

### `yarn build` fails to minify
##### 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:

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
```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 **<MyCustomInput />** component with `forwardRef` function which accepts ref as the second argument which can be used on the **<input />** element as **ref={ref}**

</p>
</details>

---

**[⬆ 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 (
<>
<div>Clicked + {ref.current} + times</div>
<button onClick={handleClick}>
Click me!
</button>
</>
);
}
```

- 1: 3 times
- 2: 4 times
- 3: 2 times
- 4: 0 times

<details><summary><b>Answer</b></summary>
<p>

##### 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.
</p>
</details>

---

**[⬆ Back to Top](#table-of-contents)**
2 changes: 1 addition & 1 deletion coding-exercise/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function App() {
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
Edit <code>src/App.js</code> and save to reload browser.
</p>
<a
className="App-link"
Expand Down
Loading