I really need some help I am trying to figure out the issue for three days but no luck so if you can help I would really appreciated ....I am trying to build a simple app with react and json-server for back end the issue I am having the data has nested object so when even I fetch the data and try to modified it is throw error says the kay in nested obj undefined !! the question how to update the state has nested obj the is the user state const [getUser, setGetUser] = useState({ first_name: '', last_name: '', age: '', gender: '', address: { address1: '', address2: '', city: '', state: '', zip: '' }, order_total: { amount: 0 }, }); and this how onChnage fun works setGetUser({ ...getUser, [e.target.name]: e.target.value }) let see I want to update city in address obj how I can do that
how to update nested object using react and json-server
335 views Asked by Hayder Jebur At
1
There are 1 answers
Related Questions in REACTJS
- ussd reader in Recket Native module
- Teams tab application returns SSO error in mobile Outlook
- Github Pages Deployment deploys a blank page
- Is there any way to glow this bulb image like a real light bulb
- Optimize LCP ReactJs
- Page in React only renders elements after refreshing
- Unable to Post Form Data to MongoDB because of picturepath
- MERN Stack App - User Avatar Upload - 500 Error After Deployment on Render
- Hooks are not supported inside an async component error in nextjs project using useQuery
- How to change the Font Weight of a SelectValue component in React when a SelectItem is selected?
- On the server side, it returns undefined but on the client side, logs the values no problem
- Multilevel dropdown with checkboxes in Select component
- TypeScript Error only on big type only when assigned to a variable
- Deployment through app engine, cloud sql database, problem connecting with server code, doesn't connect
- Data is not filtering in props. Showing passdata.map is not a function
Related Questions in JSON-SERVER
- How do I post new data directly into a nested array in my json data file?
- SyntaxError: Unexpected token 'm', "module.exp"... is not valid JSON
- how to deploy mock json data api's(json-server) and angular 17 application in apache tomcat server 9 version
- Deploying a different index page using Vercel with json-server
- json-server error: "Cannot create property 'id' on string"
- The requested module 'node:util' does not provide an export named 'parseArgs'
- NextJs server components return empty array from Json Server
- how can i make user enter home page without login and to access any thing must login useing json server in React js
- I want to have an api endpoint to get all tasks which have a startDate as Today
- React Native + Expo + Axios, why need to use 10.0.2.2 instead locahost?
- Integer "id" value automatically gets updated to string after POST method
- AxiosError Network Error to fetching jsonServer data
- How do I fix error message while trying to run json-server
- Angular json Server
- Issue Starting json-server Using npm start
Related Questions in NESTED-OBJECT
- Binding dropdown list from a nested object to a view not working (object reference not set to an instance of an object)
- With Formik and Yup, how do I display a form error for a field of a nested object?
- Vue multiselect component's label can't read nested property
- Check and Uncheck logic between Parent item and child items in React JS
- Is there a way to set attribute to sub objects in a class?
- Getting hold of dynamically generated object with the help of selectors
- How we can add and update both in nested array object in MongoDB C#
- React update nested objects with input name
- How to change value of keys in multiple nested objects at once in JavaScript
- How to use nested object values and keys
- SCAPY: Using objects (classes) multiple times in a packet/layer
- Search for multiple values within the hierarchy of the same specified folder in a flat representation of a tree structure in a Postgres jsonb table
- I have this function, I want the addresses and phones to be an array of objects not an object all dynamically, any solution please?
- Sorting array of objects in Javascript
- store an object in parent object through javascript
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
When you write:
You are adding a new key value pair to the dictionary, not updating an existing one. If you want to update an existing key value pair, for example the city, you should try the following:
Eg: