Skip to content

Commit 6970f8b

Browse files
authored
Merge pull request sudheerj#174 from ResoDevansh/usefulUpdations
fixing typo, grammatical errors in README.md
2 parents e1ad86a + fdc9885 commit 6970f8b

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

README.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ You can download the PDF and Epub version of this repository from the latest run
369369

370370
1. ### What is React?
371371

372-
React is an **open-source frontend JavaScript library** which 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.
372+
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.
373373

374374

375375
**[⬆ Back to Top](#table-of-contents)**
@@ -463,7 +463,7 @@ You can download the PDF and Epub version of this repository from the latest run
463463

464464
There are two possible ways to create a component.
465465

466-
1. **Function Components:** This is the simplest way to create a component. Those are pure JavaScript functions that accept props object as first parameter and return React elements:
466+
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:
467467

468468
```jsx harmony
469469
function Greeting({ message }) {
@@ -530,7 +530,7 @@ You can download the PDF and Epub version of this repository from the latest run
530530
531531
![state](images/state.jpg)
532532
533-
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 til the owner component decides to pass it.
533+
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.
534534
535535
536536
**[⬆ Back to Top](#table-of-contents)**
@@ -797,7 +797,7 @@ You can download the PDF and Epub version of this repository from the latest run
797797
}
798798
}
799799
```
800-
2. You can also use ref callbacks approach regardless of React version. For example, the search bar component's input element accessed as follows,
800+
2. You can also use ref callbacks approach regardless of React version. For example, the search bar component's input element is accessed as follows,
801801
```jsx harmony
802802
class SearchBar extends Component {
803803
constructor(props) {
@@ -823,7 +823,7 @@ You can download the PDF and Epub version of this repository from the latest run
823823
```
824824
825825
You can also use *refs* in function components using **closures**.
826-
**Note**: You can also use inline ref callbacks even though it is not a recommended approach
826+
**Note**: You can also use inline ref callbacks even though it is not a recommended approach.
827827
828828
**[⬆ Back to Top](#table-of-contents)**
829829
@@ -1045,7 +1045,7 @@ You can download the PDF and Epub version of this repository from the latest run
10451045

10461046
It's worth mentioning that React internally has a concept of phases when applying changes to the DOM. They are separated as follows
10471047

1048-
1. **Render** The component will render without any side-effects. This applies for Pure components and in this phase, React can pause, abort, or restart the render.
1048+
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.
10491049

10501050
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()`.
10511051

@@ -1077,9 +1077,9 @@ You can download the PDF and Epub version of this repository from the latest run
10771077

10781078
React 16.3+
10791079

1080-
- **getDerivedStateFromProps:** Invoked right before calling `render()` and is invoked on *every* render. This exists for rare use cases where you need derived state. Worth reading [if you need derived state](https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html).
1080+
- **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).
10811081
- **componentDidMount:** Executed after first rendering and where all AJAX requests, DOM or state updates, and set up event listeners should occur.
1082-
- **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.
1082+
- **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.
10831083
- **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.
10841084
- **componentDidUpdate:** Mostly it is used to update the DOM in response to prop or state changes. This will not fire if `shouldComponentUpdate()` returns `false`.
10851085
- **componentWillUnmount** It will be used to cancel any outgoing network requests, or remove all event listeners associated with the component.
@@ -1135,7 +1135,7 @@ You can download the PDF and Epub version of this repository from the latest run
11351135
11361136
*Context* provides a way to pass data through the component tree without having to pass props down manually at every level.
11371137
1138-
For example, authenticated user, locale preference, UI theme need to be accessed in the application by many components.
1138+
For example, authenticated users, locale preferences, UI themes need to be accessed in the application by many components.
11391139
11401140
```javascript
11411141
const {Provider, Consumer} = React.createContext(defaultValue)
@@ -1146,9 +1146,9 @@ You can download the PDF and Epub version of this repository from the latest run
11461146
11471147
38. ### What is children prop?
11481148
1149-
*Children* is a prop (`this.props.children`) that allow 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.
1149+
*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.
11501150
1151-
There are a number of 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`.
1151+
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`.
11521152
11531153
A simple usage of children prop looks as below,
11541154
@@ -1199,7 +1199,7 @@ You can download the PDF and Epub version of this repository from the latest run
11991199
12001200
40. ### What is the purpose of using super constructor with props argument?
12011201
1202-
A child class constructor cannot make use of `this` reference until `super()` method has been called. The same applies for ES6 sub-classes as well. The main reason of passing props parameter to `super()` call is to access `this.props` in your child constructors.
1202+
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.
12031203
12041204
**Passing props:**
12051205
@@ -2217,7 +2217,7 @@ You can download the PDF and Epub version of this repository from the latest run
22172217
22182218
87. ### Why should component names start with capital letter?
22192219
2220-
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 unrecognized tag. This convention is because only HTML elements and SVG tags can begin with a lowercase letter.
2220+
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.
22212221
```jsx harmony
22222222
class SomeComponent extends Component {
22232223
// Code goes here
@@ -2244,8 +2244,8 @@ You can download the PDF and Epub version of this repository from the latest run
22442244
22452245
#### What are the exceptions on React component naming?
22462246
2247-
The component names should start with a uppercase letter but there are few exceptions on this convention. The lowercase tag names with a dot (property accessors) are still considered as valid component names.
2248-
For example the below tag can be compiled to a valid component,
2247+
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.
2248+
For example, the below tag can be compiled to a valid component,
22492249
22502250
```jsx harmony
22512251
render() {
@@ -4741,7 +4741,7 @@ You can download the PDF and Epub version of this repository from the latest run
47414741
47424742
216. ### What is render hijacking in react?
47434743
4744-
The concept of render hijacking is the ability to control what a component will output from another component. It actually 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 enables hijacking, but by using HOC you make your component behave in different way.
4744+
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.
47454745
47464746
47474747
**[⬆ Back to Top](#table-of-contents)**
@@ -4795,7 +4795,7 @@ You can download the PDF and Epub version of this repository from the latest run
47954795
**[⬆ Back to Top](#table-of-contents)**
47964796
47974797
219. ### Do I need to keep all my state into Redux? Should I ever use react internal state?
4798-
It is up to developer decision. i.e, It is developer 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.
4798+
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.
47994799

48004800
Below are the thumb rules to determine what kind of data should be put into Redux
48014801
1. Do other parts of the application care about this data?
@@ -4809,7 +4809,7 @@ You can download the PDF and Epub version of this repository from the latest run
48094809

48104810
220. ### What is the purpose of registerServiceWorker in React?
48114811

4812-
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 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's for now. It's all about adding offline capabilities to your site.
4812+
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.
48134813

48144814
```jsx
48154815
import React from 'react';
@@ -4853,7 +4853,7 @@ You can download the PDF and Epub version of this repository from the latest run
48534853
**[⬆ Back to Top](#table-of-contents)**
48544854
48554855
223. ### How to prevent unnecessary updates using setState?
4856-
You can compare current value of the state with an existing state value and decide whether to rerender the page or not. If the values are same then you need to return **null** to stop re-rendering otherwise return the latest state value.
4856+
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.
48574857
48584858
For example, the user profile information is conditionally rendered as follows,
48594859
```jsx
@@ -4913,7 +4913,7 @@ You can download the PDF and Epub version of this repository from the latest run
49134913
**[⬆ Back to Top](#table-of-contents)**
49144914
49154915
225. ### How to use class field declarations syntax in React classes?
4916-
React Class Components can be made much more concise using the class field declarations. You can initialize local state without using the constructor and declare class methods by using arrow functions without the extra need to bind them.
4916+
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.
49174917
49184918
Let's take a counter example to demonstrate class field declarations for state without using constructor and methods without binding,
49194919
```jsx
@@ -5725,8 +5725,8 @@ You can download the PDF and Epub version of this repository from the latest run
57255725
**[⬆ Back to Top](#table-of-contents)**
57265726
57275727
271. ### Why are you not required to use inheritance?
5728-
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 in an explicit and safe way.
5729-
Whereas, If you want to reuse non-UI functionality between components, it is suggested to extracting it into a separate JavaScript module. Later components import it and use that function, object, or a class, without extending it.
5728+
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.
5729+
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.
57305730
57315731
**[⬆ Back to Top](#table-of-contents)**
57325732
@@ -6029,7 +6029,7 @@ You can download the PDF and Epub version of this repository from the latest run
60296029
export default logProps(FancyButton);
60306030
```
60316031
6032-
Now lets create a ref and pass it to FancyButton component. In this case, you can set focus to button element.
6032+
Now let's create a ref and pass it to FancyButton component. In this case, you can set focus to button element.
60336033
60346034
```javascript
60356035
import FancyButton from './FancyButton';
@@ -6118,7 +6118,7 @@ You can download the PDF and Epub version of this repository from the latest run
61186118
287. ### What is diffing algorithm?
61196119
React needs to use algorithms to find out how to efficiently update the UI to match the most recent tree. The diffing algorithms is generating the minimum number of operations to transform one tree into another. However, the algorithms have a complexity in the order of O(n3) where n is the number of elements in the tree.
61206120
6121-
In this case, for displaying 1000 elements would require in the order of one billion comparisons. This is far too expensive. Instead, React implements a heuristic O(n) algorithm based on two assumptions:
6121+
In this case, displaying 1000 elements would require in the order of one billion comparisons. This is far too expensive. Instead, React implements a heuristic O(n) algorithm based on two assumptions:
61226122
61236123
1. Two elements of different types will produce different trees.
61246124
2. The developer can hint at which child elements may be stable across different renders with a key prop.
@@ -6806,13 +6806,13 @@ ReactDOM.render(
68066806

68076807
```
68086808
6809-
**How to prevent it:** Make sure your state variables are immutable by either enforcing immutability by using plugins like Immutable.js, always using `setState` to make updates and returning new instances in reducers when sending updated state values.
6809+
**How to prevent it:** Make sure your state variables are immutable by either enforcing immutability by using plugins like Immutable.js, always using `setState` to make updates, and returning new instances in reducers when sending updated state values.
68106810
68116811
**[⬆ Back to Top](#table-of-contents)**
68126812
68136813
332. ### What is the difference between useState and useRef hook?
68146814
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.
68156815
Essentially, useRef is like a “box” that can hold a mutable value in its (.current) property.
6816-
2. useState allows us to update the state inside components. While useRef allows to reference DOM elements.
6816+
2. useState allows us to update the state inside components. While useRef allows refrencing DOM elements.
68176817
68186818
**[⬆ Back to Top](#table-of-contents)**

0 commit comments

Comments
 (0)