I’m pretty new to React, and I’m making an ecommerce website for practice. I have a cart component that dynamically renders cart items from an API, but I narrowed the problem 100% down to the front end. On the initial render, it works fine, everything that is in the database cart appears, however after I press the “Delete from Cart”
Tag: reactjs
how can i add key value pair in array inside another array
// I have the following response : //and I want to add this key-value pair in 2 places (“completed”: false) to make it look like the following response: ……………………………………………………………………………………………………….. Answer Array.map can solve your problem. You can check the completed demo:
File gets uploaded despite limit being set, input not getting emptied
I’m probably missing something obvious but once I confirm the ok in the window.alert the file name still appears next to Choose File? So it’s being uploaded to the input still. How do I prevent this? Answer Empty the value property of the input. For that change e.target.file = “” to e.target.value = “”. Here is your hole code:
mapping doesn’t work inside react-router-dom’s Routes component
instead of type everything manually ,I just want to render my routes as an array. and in my app.js file, I did something like this: But its giving error , while I tried to execute it. but but, If I put like this it works: <Route path=”/” element={} /> update- non-auth layout piucture I think , I did some silly
Multiple Buttons with their own Events in ReactJS
What would be the best way to handle multiple buttons that show/hide their respective DIVs. Example of the Code I have below. As you can see it’s set to handle just the first button. I need a method to continually add more buttons that show/hide their own DIVs. Example: When Button(A) is clicked DIV(A) fades in. If Button(A) is clicked
How to display the desired information on click ReactJS
My page is divided into right and left parts. On the left side there are 3 buttons, and on the right side there is a list with 3 texts. They are in different files. I want the corresponding text to come first in the list when the button is clicked. The functionality is similar to tabs, but I don’t know
form.js:24 Uncaught TypeError: Cannot destructure property ‘name’ of ‘e.target’ as it is undefined
im getting some error saying cant destructure the property ‘name’ of e.target undefined I will be grateful for any help. unable to assign any value in the input field. I need to sign up as a client, but when I enter the value they can’t assign, what can i do ? i also writen a code for email and password
ApolloError: Fragment was used, but not defined
I have this in my complicated app: Basically, I have an export button which will export a CSV of my GraphQL data. I manually call client.query to fetch the latest data on click of the button, but it throws an error saying it can’t find the used fragment StuffTable. How do I include that fragment in the query? I am
How access the original observed node by MutationObserver when subtree is true?
How can I access the original target node when using MutationObserver with options childList and subtree set to true? On the callbacks, the target is changed to whatever node has mutated, and this is expected as per the MDN documentation, but my intention is to always be able to look at the original node, so I can evaluate if it
Display file name after selecting it
I want to create a button on my site that will allow the user to upload a file from their device (computer, phone). I have already made this button and it opens a window where you can select a file. But I ran into a problem: I would like to display the name of this file on the page. I