If you select any file its working perfectly but after selecting any file again if you click choose file button and not select any file then error occur “Cannot read properties of undefined (reading ‘name’)” how to resolve this error. I also gave filename===undefined but its not working Answer Multiple issues in your code. Please read on. The first rule
Tag: reactjs
react-i18next ignores options parameter
I wanted to organize better the language translation files of my project having to nest objects in the language file. Without nesting everything works fine Even nesting objects I can access them by passing the attribute directory in the t() function (ie: t(‘section.subsection.text’) Documentation’s solution doesn’t work for me and I don’t know why I already tried printing the useTranslation
How to dynamically create multiple alerts inside mui v5 Snackbar
I am calling an API to do few actions. I want to take the response of each action and show it inside Snackbar/alert. I am able to show only the first response and nothing else even after iterating the messages in a map. Here is my business logic calling the api setNotify will open the Snackbar with the alerts The
React get value from a class
I have a component where i get the distance from one point to another, with Google Maps (DirectionsRenderer). What i want, is to use this data in a h1 This is my return EDIT: ShowProduct.js (This is where i get the distance) ProductCard.js (This is where want to use it) Answer You need to set up a state using useState
React JS fetching data (error: Cannot read properties of undefined)
i am just trying to learn JavaScript. I have to create a web application for school. Now i am trying to fetch data from a self written api. The backend is written with express, the frontend with JavaScript. I have got a overview page, where all products are shown. After clicking on the detail button, the user should be able
Render div with state only on phones
is there some way how to render div conditionally with state but only for mobiles? I have show more button, but i need it only for phone resolution, also I need to display that div with className text every time on desktop Answer you can set the active class in the media query. At first, you can this div display
Paypal dynamic value in react js
I need help with my project I want to add a dynamic option to the PayPal payment process. ( change the value to be dynamic ) the default option is value: ‘0.01’ and the dynamic payment in my project is cart.subtotal.formatted_with_symbol I try to add [const {amount} = cart.subtotal.formatted_with_symbol;] this line to try to change the value to value: amount
How to make a select input that is dependent on other inputs to always show a default value in React?
I have two radio buttons: radio1 and radio2, and one select input. The Select values depend on the radio buttons. I want to set the select value to 1 whenever I select radio1. I’ve tried setting defaultValue and value to the select input but every time I switch back to radio1 from radio2, the value is always set to 2.
Reactjs Dynamically call components having cards under tabpanels using array
This is where Tab header and tab content is defined, expectation is Tabs_content has component name, and under tabpanel it should traverse array tabs_content and display component < AddQueueCard /> and call the component shown in image 3 Answer Just pass Component itself , but its better to have a separate component dictionary and loop through that for rendering dynamic
Adding object values to useMemo hook for React
I am attempting to create a react-table component using data that is pulled from a database. From the documentation I have read (https://react-table.tanstack.com/docs/quick-start), it seems like the react-table library uses a useMemo hook to create the data which will be displayed on the table. However, I am having trouble actually adding data to the useMemo hook, since I am not