setState() and prevState

I've been thinking about how we use setState(). Often it looks like this: this.setState({ user: ...this.state.user, value: "bar" }) When what is recommended, and safer to use is something like this: this.setState(prevState => ( { user: ...prevState.user, value: "bar" }) }What do you think? Links https://stackoverflow.com/…

Hot Module Replacement (HMR) with React Create-React-App without ejecting for a fast development cycle

If you have a Create-React-App, follow this guide: Firstly, install the dependencies: npm install --save-dev react-app-rewired react-hot-loader react-app-rewire-hot-loader @hot-loader/react-dom In your root folder, create a file config-overrides.js const rewireReactHotLoader = require('react-app-rewire-hot-loader') /* config-overrides.js */ module.exports = function override(config, env) { config = rewireReactHotLoader(config, env) config.resolve.alias = { ...config.resolve.…

flex

.parent { display: flex; flex-wrap: wrap; align-content: stretch; height: 100%; } .child { width: 30%; }…

js

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.16.0/themes/prism.min.css"> <style> pre[class*=language-] { margin: 1.75em 0; } </style>…