I have summarized and compiled a list of React.JS best practices from various sources across the internet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GET VERSION | |
npm -v (or --version) | |
# GET HELP | |
npm help | |
npm | |
# CREATE PACKAGE.JSON | |
npm init | |
npm init -y (or --yes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This API wrapper is useful because it: | |
1. Centralizes our Axios default configuration. | |
2. Abstracts away the logic for determining the baseURL. | |
3. Provides a clear, easily consumable list of JavaScript functions | |
for interacting with the API. This keeps API calls short and consistent. | |
*/ | |
import axios from 'axios'; | |
let api = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GET VERSION | |
yarn -v (or --version) | |
# GET HELP | |
yarn help | |
# CREATE PACKAGE.JSON | |
yarn init | |
yarn init -y // Use defaults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Example extends React.Component< | |
Props, | |
State, | |
Snapshot | |
> { | |
static getDerivedStateFromProps( | |
nextProps: Props, | |
prevState: State | |
): $Shape<State> | null { | |
// ... |
Answer: All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.
Source: tutorialspoint.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.youtube.com/watch?v=UB1O30fR-EE&list=PLillGF-RfqbYeckUaD1z6nviTp31GLTH8 |
The package that linked you here is now pure ESM. It cannot be require()
'd from CommonJS.
This means you have the following choices:
- Use ESM yourself. (preferred)
Useimport foo from 'foo'
instead ofconst foo = require('foo')
to import the package. You also need to put"type": "module"
in your package.json and more. Follow the below guide. - If the package is used in an async context, you could use
await import(…)
from CommonJS instead ofrequire(…)
. - Stay on the existing version of the package until you can move to ESM.