const { loading, data, error } = useQuery(SOME_QUERY) const [state, setState] = React.useState([]) React.useEffect(() => { // do some checking here to ensure data exist if (data) { // mutate data if you need to setState(data) } }, [data])
1. npm i -D prettier 2. create .prettierrc.json { "trailingComma": "all", "tabWidth": 2, "singleQuote": true, "jsxBracketSameLine": true, "semi": false } 3. npm i -D eslint-config-prettier 4. in package.json, add this: "eslintConfig": { "extends": [ "react-app", "react-app/jest", "prettier" ] }, 5. install extension in VS Code Prettier extension