This file contains hidden or 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
{ | |
"editor.formatOnSave": true, | |
"editor.defaultFormatter": "esbenp.prettier-vscode", | |
// ^ Prettier will format files on save. | |
"editor.codeActionsOnSave": { | |
"source.fixAll": true | |
}, | |
// ^ ESLint will fix possible issues on save. | |
// "javascript.validate.enable": false |
This file contains hidden or 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
export const i18nContext = React.createContext(null); |
This file contains hidden or 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
// Assuming you have a group of modules described within individual files: | |
// - group/module1.js | |
// - group/module2.js | |
// - group/module3.js | |
// ...where each module*.js file has a corresponding named export: | |
// - group/module1.js |
This file contains hidden or 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
[options] | |
module.name_mapper.extension='module.css' -> 'CSSModule' | |
module.name_mapper.extension='svg' -> 'SVGModule' | |
module.system=haste |
This file contains hidden or 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
// Outside props goes here first to be transformed according to Component's logic | |
export const useComponentState = props => { | |
const { disabled } = props; | |
const [loggedIn, setLoggedIn] = React.useState(initialLoggedIn); | |
const onLogInButtonClick = () => { | |
if (!disabled) { | |
setLoggedIn(true); |
This file contains hidden or 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
// External state example (Redux e.g) | |
class SimplerReactForm extends React.Component { | |
handleInputChange = (e) => { | |
const { name, value } = e.target | |
this.props.onChange({ | |
...this.props.values, | |
[name]: value | |
}) |
This file contains hidden or 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
const asyncTimeout = (timeout) => new Promise( | |
resolve => setTimeout(resolve, timeout) | |
) | |
export default asyncTimeout |
This file contains hidden or 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
const value = 'text' | |
// - without else statement | |
// single-line | |
return ( | |
<div> | |
{ | |
value && <span>{value}</span> | |
} |