I am trying to transform the data below from: To: I have been puzzling away at this for quite a while and can only get it looking like this, which is just seperate objects rather than a single object as part of an array of objects (there are other book objects in the returned JSON from my db the function
Tag: reactjs
Why is my foreach and map return undefined [duplicate]
This question already has answers here: What does `return` keyword mean inside `forEach` function? [duplicate] (2 answers) Closed 22 days ago. I have a packet system where you can have products in a packet. So if anyone buy a packet I add this in shopping cart, if he buy it again then I check if the packet id…
axios error react interceptors request is not a function
i have a configuration with axios i am testing a feature to receive a list of students from an api, the problem is that it sends me an error: TypeError: constants_api_constants__WEBPACK_IMPORTED_MODULE_1_.default.interceptors.request is not a function For my axios configuration I use: How I resolve my promise…
React Class Component setState undefined
I am attempting to update a variable from “” to a string of text with an onClick method in React. I’ve approached this several different ways following examples on the web and Youtube but all are resulting in various error messages. This is the latest attempt and I’m receiving an error…
Access React state of function enclosed inside useRef doesn’t update
I’m trying to access React state inside a function enclosed inside of useRef. However, even with a helper function bound to App to access the state, the state never updates inside of the useRef function. Answer The argument passed to useRef is only considered when the component mounts. Only at that time…
Antdesign table not rerendering on new column values
I am having trouble rerendering the columns of my table, the library i am using is ant design and I am trying to create a feature where I reorder the column of the table on demand. I have created an example the issue here: https://replit.com/@coupacoupa/Ant-Design-column-reordering In the example, I created a…
Uncaught TypeError: Cannot read properties of undefined (reading ‘name’) | Material UI
I’m trying to view the fetched data on MUI Autocomplete, but I get this error I don’t why, the stat is fetched from MongoDB and I’m just trying to view the name of the category as an option. The Code: This is how the data is showing in Mongodb Answer So I added this and it worked getOptionLa…
React state does not update accordingly when popping an array
I wrote a simple component in React which is supposed to remove the last element of an array when a button is clicked, but despite console logging the correct value, my React state is not being updated accordingly (when viewing the components with React Developer Tools) and hence the output is not changing. I…
How do I keep my ScrollView from snapping back to the top? (React Native)
In order to create a scrollable UI, I decided to use a ScrollView to display all my components. However, whenever I try to scroll to the bottom, the app bounces back to the top as soon as I release my finger. I’ve tried adding styling to the ScrollView and its parent view, but it doesn’t seem to h…
How can I use the next array element from a map function?
I have a JSON file with 20k entries in it. The even number indexes are all ID numbers. The element right after each ID number is the matching string for that ID that I need to put in to a table. ID Matching Str ID Matching Str 1 String for 1 3 String for 3 2 String for 2 4