Replacing and rendering the whole real DOM is costly!
Virtual DOM is a representation of the actual DOM
Its purpose is to identify which parts of the real DOM need to be changed upon changes, by comparing the new virtual DOM result against the previous one.
The delta then gets applied on the real DOM.
E.g. only one element gets updated within a long list instead of
the whole list.
Use virtualization as a "last resort", usually there are other places which are easier to fix.
React Lazy / Suspense
It is the closest thing to a mocking server without having to
create one.
—
Mock Service Worker Docs
Source: https://mswjs.io/docs/
The node-request-interceptor library is used to intercept HTTP requests.
src/mocks/server.ts
src/setupTests.ts
src/handlers.ts
Or: How to break out of Virtual DOM
Refs permit to obtain a reference to a real dom element
Automatically set focus on page load
Does not work! – ref is a special prop (the other one is key)
The browserslist configuration controls the outputted JavaScript so that the emitted code will be compatible with the browsers specified.
Polyfills still need to be added manually!
Your code is always consistent, as is the code from the rest of your team. No more bikeshedding!
Let's install it either locally npm i -D prettier or run it with npx prettier .
Prettier is heavily opinionated. Luckily there are a lot of options to customize it to your liking.
Add a .prettierrc.js file to your project:
module.exports = {
endOfLine: 'lf',
singleQuote: true,
trailingComma: 'all',
quoteProps: 'consistent',
}
Add an npm script to the package.json :
"scripts": {
"pretty": "prettier --write \"src/**/*.{js,json,
yml,yaml,css,scss,ts,tsx,md}\"",
},
Multiple configurations and plugins can be configured in the extends field value.
If multiple configurations or plugins specify contradicting values for the same rule, the latter will be applied.
Rules can be overridden in the rules field value.
One option: framer-motion
Source: Plasmic Blog – How React server components work: an in-depth guide