score:1
Accepted answer
you expect object in your code however your api response is an array of objects. it's clearly visible from your logs.
to verify it you can simple try
setuser(result.data[0]); // instead of setuser(result.data);
this line below - always would result undefined
values.
since you are assigning an array, your variable destructuring like this would not work
const { firstname, lastname, collectorcode, financecompany } = user;
.
you might want to change the logic how to store user data since api response and current state does not really match.
Source: stackoverflow.com
Related Query
- setUser does not seem to get set when pulling from database
- OnChange method does not work when trying to get text from input - reactjs
- Why does my set state does not get updated when given a value?
- useEffect does not get triggered when getting redirected from another page using Ionic
- jsdom 9.1+ does not set document.activeElement when focusing a node
- ReactJs: fontSize does not change when calling it from a font change method
- Material UI TextField label does not move up when the value for TextField is set porgramatically
- Component does not receive props from getStaticProps when wrapped with HOC
- React Router "Link to" does not load new data when called from inside the same component
- Implementing Twilio Api call from a CURL example to js returns status code of 200 but does not seem to update data
- Why React component get re-rendered only once when state does not change?
- textarea does not auto focus even when set to auto focus
- no argument props method does not get called from child component in react
- I get data from Api but when I try to set the value with useState it give me an empty object
- "Property does not exist on type 'never'" when i try to access a json data from API response
- ReactJS: State does not update upon onChange when initial state is from props
- useState does not set state when initalized by RouteProps
- setState() does not change state when called from element that depends on state to render
- Child component does not set the initial value passed from the parent: ReactJS
- Array key does not get interpolated when making object
- React router Redirect does not work when route comes from another component
- Redux is able to set characters to an array however the remove action does not seem to reach the reducer
- Drawing audio as sound bars on a canvas does not overwrite last drawing when canvas.height not set
- setState does not set the state properly, when dropdown values changes
- Why does TS do not get React state assertion from Interface?
- When using Map, CSS does not get applied
- Recoil: parent state does not update when atomFamily is set
- How to get user information from database when the only thing in client browser is the AuthToken?
- React Component does not render when clicking CardActionArea from Material UI
- Reactjs onClick not rerendering data when sent to child component to get info from api
More Query from same tag
- React component State clears after adding additional query parameters to the URL
- Verifying if the user is owner of the email address in firebase
- Debugging Redux / React with Webpack
- CORS policy: The 'Access-Control-Allow-Origin' problem when deployed NextJS app on Nginx server tries GET request to local Express server
- Is there a downside to disabling create-react-app's SKIP_PREFLIGHT_CHECK?
- ReactJS - Added non-passive event listener to a scroll-blocking 'mousewheel' event
- styled-components not working with create-react-library
- How do you get any useful call stack information when debugging react native?
- Passing props/state between two functional child components in react?
- What is the purpose of react-helmet?
- Google App Engine, index.html cached after deploy in express/react app
- document is undefined in document.getElementById, while writing unit test cases in Jest
- React-Mobx Warning: A component is changing an uncontrolled input
- Next js dynamic API call with Express
- How to send a message to everyone execpt the sender socket.io
- added data don't update automatically in useEffect() Need refresh browser to get the last addition
- Documenting Javascript/React
- how to change states more efficiently?
- useEffect show a warning if I call a function in throw props?
- Create Role Based Authorization in Auth0 and NextJS
- Warning: Invalid DOM property `tabindex`. Did you mean `tabIndex`?
- Could not resolve dependency: reactjs "npm install" on MacOS
- React Hooks - Changing state inside child does not reflect in parent
- React defer render until async componentDidMount
- Can "font-variation-settings" be used in the styled-components .attrs method?
- GHCJS: How to use a JS library that is intended to be used with npm
- React 18: how to force synchronous rendering?
- React TS function argument types
- React formik - how to run a function after setValues
- Using React.js lazy loading when I navigate to a nested route the main bundle doesn't load