Skip to content

Commit 6e68b6e

Browse files
committed
Review questions and answers
1 parent 5a31d13 commit 6e68b6e

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ To encourage us and if you like the project then click star(💫) and also any P
44

55
<img src="images/logo.jpeg" width="600" height="300">
66

7+
![](https://img.shields.io/github/stars/sudheerj/reactjs-interview-questions/editor.md.svg) ![](https://img.shields.io/github/forks/sudheerj/reactjs-interview-questions/editor.md.svg) ![
8+
79
Below is a list of ReactJS interview questions and answers.
810
-------------------------------------------------------------------
911
| No. | Questions |
@@ -21,7 +23,7 @@ Below is a list of ReactJS interview questions and answers.
2123
|10 | [What is the difference between state and props?](#what-is-the-difference-between-state-and-props)|
2224
|11 | [Why should not we update the state directly?](#why-should-not-we-update-the-state-directly)|
2325
|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)
24-
|13 | [What is the difference between HTML and React event handling?](#what-is-the-difference-between-html-and-react-event-handling)|
26+
|13 | [What is the difference of event handling between HTML and React?](#what-is-the-difference-of--event-handling-between-html-and-react)|
2527
|14 | [How to bind methods or event handlers in JSX callbacks?](#how-to-bind-methods-or-event-handlers-in-jsx-callbacks)|
2628
|15 | [How to pass a parameter to an event handler or callback?](#how-to-pass-a-parameter-to-an-event-handler-or-callback)|
2729
|16 | [What are synthetic events in ReactJS?](#what-are-synthetic-events-in-reactjs)|
@@ -391,18 +393,18 @@ Instead use setState() method. It schedules an update to a component’s state o
391393

392394
12. ### What is the purpose of callback function as an argument of setState?
393395
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.
394-
**Note:** It is recommended to use lifecycle method rather this callback function.
395396
```
396397
setState({name: 'sudheer'}, () => console.log('The name has updated and component re-rendered'));
397398
```
398-
13. ### What is the difference between HTML and React event handling?
399-
Below are the few differences between HTML and React event handling,
399+
**Note:** It is recommended to use lifecycle method rather this callback function.
400+
13. ### What is the difference of event handling between HTML and React?
401+
Below are the few differences of event handling between HTML and React,
400402
1. In HTML, the event name should be in lowercase.
401403
```
402404
<button onclick="activateLasers()">
403405
```
404406

405-
Whereas in ReactJS it follows camelCase convention,
407+
Whereas in ReactJS it follows camelCase convention,
406408

407409
```
408410
<button onClick={activateLasers}>
@@ -414,7 +416,7 @@ Whereas in ReactJS it follows camelCase convention,
414416
<a href="#" onclick="console.log('The link was clicked.'); return false"/>
415417
```
416418

417-
3. Whereas in ReactJS you must call preventDefault explicitly,
419+
3. Whereas in ReactJS you must call preventDefault method explicitly,
418420

419421
```
420422
function handleClick(e) {
@@ -425,11 +427,11 @@ Whereas in ReactJS it follows camelCase convention,
425427

426428
14. ### How to bind methods or event handlers in JSX callbacks?
427429
**(Or)**
428-
### How to use this in JSX callbacks?
430+
### How to use this keyword in JSX callbacks?
429431

430432
There are 3 possible ways to achieve,
431433

432-
1.**Binding in Constructor:** In JavaScript classes, the methods are not bound by default. The same thing applies for ReactJS event handlers defined as class methods. Normally we bind them in constructor as follows,
434+
1.**Binding in Constructor:** In JavaScript classes, the methods are not bound by default. The same thing applies for ReactJS event handlers defined as class methods. Normally, we bind them in constructor as follows,
433435
```
434436
constructor(props) {
435437
super(props);
@@ -464,15 +466,15 @@ There are 3 possible ways to achieve,
464466

465467
You can use an arrow function to wrap around an event handler and pass parameters:
466468

467-
```
469+
```javascript
468470
<button onClick={() => this.handleClick(id)} />
469471
```
470-
This is equivalent to calling .bind as below,
471-
```
472+
This is equivalent to using **bind** method as below,
473+
```javascript
472474
<button onClick={this.handleClick.bind(this, id)} />
473475
```
474476
16. ### What are synthetic events in ReactJS?
475-
SyntheticEvent is a cross-browser wrapper around the browser's native event. It's API is same as the browser's native event, including stopPropagation() and preventDefault(), except the events work identically across all browsers.
477+
**SyntheticEvent** is a cross-browser wrapper around the browser's native event. It's API is same as the browser's native event, including *stopPropagation()* and *preventDefault()*, except the events work identically across all browsers.
476478

477479
17. ### What is inline conditional expressions?
478480

0 commit comments

Comments
 (0)