score:4
Accepted answer
const selectorData = useSelector(...);
const [data, setData] = useState(selectorData);
useEffect(() => {
setData(selectorData)
}, [selectorData])
Source: stackoverflow.com
Related Query
- useSelector can not be called inside a callback
- useState not re-rendering component if it is called inside callback function
- How can I make a request to an API based on the response from another request? React Hook "useSwr" cannot be called inside a callback
- Not sure if callback inside d3.json get called
- Hooks can only be called inside of the body of a function component. useState is not working
- Invalid hook call. Hooks can only be called inside of the body of a function component
- React Hooks Error: Hooks can only be called inside the body of a function component
- Invalid hook call. Hooks can only be called inside of the body of a function component when apply style to class base component with material-ui
- react-router-dom: Invalid hook call, Hooks can only be called inside of the body of a function component
- Can not update state inside setInterval in react hook
- UI doesn't update until tap on the screen when setState is called inside a realm listener callback
- React Hook "useCategory" cannot be called inside a callback
- why I can not use function keyword to define a function inside a reactjs class
- BrowserRouter causing Invalid hook call. Hooks can only be called inside of the body of a function component
- Invariant Violation: Hooks can only be called inside the body of a function component
- React Using useState/Hooks In HOC Causes Error "Hooks can only be called inside of the body of a function component"
- React + Antd + Rollup Component Library "Error: Invalid hook call. Hooks can only be called inside of the body of a function component"
- Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons
- React Hooks can only be called inside the body of a function component
- React Hook “useInterval” cannot be called inside a callback
- Hooks can only be called inside the body of a function component error
- React 17.0.1: Invalid hook call. Hooks can only be called inside of the body of a function component
- React: Invalid hook call. Hooks can only be called inside of the body of a function component
- Receiving error - Hooks can only be called inside of the body of a function component when implementing React Spring basic example
- React: Google "One Tap" callback function not being called
- Invalid hook call. Hooks can only be called inside of the body of a function component when i call useQuery in useEffect
- Invalid hook call. Hooks can only be called inside of the body of a function component using react-apollo
- React setState callback not called for external (npm packaged) component
- React Hook "useState" cannot be called inside a callback
- Why is react state(array) empty inside callback function? Why is it not using the updated value from outer scope?
More Query from same tag
- VSCODE not recognizing .env* files for markup porpuses and not recognizing .env.local.* files
- Show a loader during timeout? React
- Mapping properties of a child array to elements of a parent array being mapped (React, Material-UI)
- How to access redux form values in another component
- Not allowing space in input field React
- axios: Unhandled Rejection (TypeError): Cannot read property 'error' of undefined
- React components not rendering on Heroku
- Why useState is throwing error when used in main App functional component?
- Loop through array and populate matrix - JS
- How to ensure App component is loaded before displaying another component
- Update a select's options based on another dropdown, using React
- Expand animation with requestAnimationFrame and React doesn't work sometimes
- Difference between passing event handler prop as arrow function or function reference
- undefined error for the text box using usereducer hooks
- React Select menu - Select multiple items - Advanced
- How to do request on page load, react hooks
- Redux store element seems to be null or undefined
- state neither updated from useState nor useEffect inside useState
- Why my navigator is not working?
- How to render a stateless functional component from another component
- CSS Changes not reflected on associated state change in React with React Hooks
- Importing Material-ui components at once
- React Js Math Issues
- I have a toggle in the main component (show & hide a div), but I want to move the button that activates it to a secondary component. how do I do it?
- Class component: Cannot read property 'user' of undefined
- Replace Parent component with Child component
- Warning : Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application
- React - Axios data does not render the data once fetched
- React project giving error after refresh in nginx
- React Hooks Auth0-js Context Hook Not Updating