score:1
Accepted answer
its because the function that you pass to usereducer is returning a function instead of a state object. try refactoring it to this:
function filestatusreducer(state, action) {
switch (action.type) {
case "uploading":
return {
...state,
uploading: !state.uploading,
status: "uploading..."
};
case "error":
return {
...state,
status: action.message
};
default:
break;
}
}
you can read more about usereducer here.
Source: stackoverflow.com
Related Query
- React Hooks Error Handling Turns State To Function
- Handling state when making multiple function calls in React with hooks as a parameter
- Handling React Context in App.js Component - error Hooks can only be called inside the body of a function
- I am changing React Classes to React Hooks and getting error on setting state on onChange() function
- React hooks function component prevent re-render on state update
- Receiving error - Hooks can only be called inside of the body of a function component when implementing React Spring basic example
- React Hooks - function inside function component passed as prop can't access state
- React Hooks state not working properly when the function calling it is called in another function
- Type Error "Map" is not a function while using react hooks
- React hooks not returning updated state values inside callback function from library events (FabricJS)
- React hooks updated state not passed to function
- React hooks state undefined on handle function
- How to pass state value to a callback function using React Hooks
- React Hooks setState function not setting state
- Make sure state is set before function is called react hooks
- Getting this error "Invalid hook call. Hooks can only be called inside of the body of a function component." inside a react functional component?
- Setting Multiple state using common function in React Hooks
- Formik hooks "useField" throws error stating that the component is not a React function component
- Handling File Upload state in React with hooks
- React navigation with hooks and header function - state is not updating
- React don't remember firebase state Error this.setState is not a function
- Updating component state by Listening to socket events inside react hooks or handling them inside middleware? what are the downsides of each one?
- React Hooks: Instantiating state hooks on validation Error: Invalid hook call. Hooks can only be called inside of the body of a function component
- Call function only in specific state in React with Hooks
- Error with calling React Hooks inside of Function Component
- React hooks - set state of Parent from child via function
- Passing a function as a callback to a React state created with hooks did not reflect new value of variable
- React Hooks TypeScript inheriting parent state & function types in child
- React giving error when used connect function to provide state to Hoc
- React Use State Hook error TypeError: setUser is not a function
More Query from same tag
- Command `run-android` unrecognized. Make sure that you have run `npm install` and that you are inside a react-native project
- Looping with useState gets and unique key error
- React map with opening and closing tags
- Best Way to Implement Login with this React Example
- Redirection with useEffect() Not Working?
- Call multiple functions onChange event -- React
- TypeScript error - property component does not exist on React mui MenuItem
- How to create external download link in React?
- Add styling to a column of a D3 heatmap programmatically
- React Testing Library: How to test components that contain useLocation()?
- React Typescript: return array of Jsx elements
- Populate select dropdown with directory names
- Pass function from parent to child
- How do i choose import/export in React
- How can I set the state in a static react function?
- Keep getting TypeError: Cannot read property 'map' of undefined when I click on checkbox, dont know where the problem is
- How to properly mock named export children components with jest
- If passing an OnChange() as a prop, can it receive multiple functions in the parent component on ReactJs?
- Get data from fetch React
- Rendering Polymer 1.0 elements with child content using React
- How to make Next.js "see" the react-dom package?
- ReactJS: How do I go the next page after condition is true?
- Use an array of options in the different component react
- Generate React form fields from JSON
- Redux's combineReducers and TypeScript
- Call a React component to show up like an alert function
- React hook missing dependency
- React Native: fetch request failed with error - TypeError: Network request failed(…)
- Is there a cleaner way to check if a deep nested node exists?
- Lifting form submitted data in react