score:1
just put a condition over res
if it is not actually undefined
product.getall(function(res) {
__this.setstate({ products: (res || __this.state.products) });
});
hope it helps.
score:1
is res
an array. map only works for arrays. use console.log(res)
to check if it's an array it not. if not convert it to an array
score:1
the problem is at __this.setstate({ products: res });
essentially, you're getting this error because res
is not of array type, so you have to check it and ensure that it is an array type as others have mentioned.
if you're still getting the same error, i suggest you console.log res
and add it to your question.
Source: stackoverflow.com
Related Query
- React setState can only update a mounted or mounting component
- React Refs woth setState giving Maximum update depth exceeded.
- React Native / Redux - setState - Cannot update during an existing state transition
- Cannot update particular property of object in react js using setState
- React hooks - setState does not update state properties
- React setstate can only update a mounted or mounting component -- on rerender
- react setState doesn't change state even when I am using react update add on
- React setState componentDidUpdate React limits the number of .. when trying to update the state based on updated state
- setState update array value using index in react
- setstate cannot update during an state transition - react
- Update react setState with mouse Event values
- React component : setState worked but didnt update component
- How to run React useEffect only once and property update state with setState
- React update component after setState
- how to update specific index of integer array in functional component setState in react js
- React setState inside componentDidUpdare leads to Maximum update depth exceeded
- setInterval in react does not update the setState
- React setState update is happening late ( n-1) , it seems i am lagging by one
- Use SetState to update one of the item in array object in react
- React Hooks setState on update to push new object return duplicates / multiple object per each push
- React : can't update my state with setState
- setState won't update React Native
- RX + React setState - avoid “Cannot update during an existing state transition”?
- update empty object, {}, using setState in React functional component
- React setState does not update a state array value
- React setState doesn't update the state after submitting input form
- Array object update React SetState
- React state update not working with setState
- React useEffect: setState in return function does not update state in time
- React JS : grandparent component's setState method doesn't update state of a grandchild input field onChange event click
More Query from same tag
- 'dispatch' Uncaught TypeError React-Redux
- Hide/Show content using ReactJS
- React: re-render even if there aren't changes in state
- Quill editor not rendering in React
- SVG linear gradient doesn't work on other elements
- Trying to convert HTML code that I get from server to Image , but gives me an error, in ReactJS
- Typescript react context + Type '{}' has no call signatures
- Creating universal React components
- 404 Not Found Next.js error on React-Query fetch
- How to send body data and headers with axios get request?
- How do I fix my navbar display over divs?
- Destructuring props in the function parameters using TypeScript
- setTimeout() in componentDidMount() does not work
- How to grab (orderId) payload value in form body to update the status of the order?
- React: Making field editable that is also updated from outside
- Is it possible to use conditional inside a react component?
- Updating NavBar on Logout Reactjs
- You may have returned undefined, an array or some other invalid object
- Dynamically assigning values in AJAX js calls
- ReactJS inline-style absolute top: "100vh" not working correctly
- Bootstrap responsive menu - tabs into select list
- How to call function in all children in React
- Set title onSubmit based on current SELECT OPTION VALUE - react
- Type not assignable (React + Typescript + Firebase)
- FIrebase Query from React Returning Wrong Snapshot
- How to make a border-radius for Skeleton by react-loading-skeleton?
- Cannot read property 'map' of undefined because reducer has problems
- Can't pass a State from parent Component to Child (pomodoro clock state counter)
- Best way to handle undefined values in ReactJS?
- How can I set/fake the proptype of a component