i try to convert array of date to array of month in react when i push convertedDateToMonths to array every time i rewrite month in output i got only 1 month when i do console.log(month) what i do wrong ? Answer You need to call the setMonth function with the updated table and not on each .map loop. So just
Tag: reactjs
Need Help Figuring Out State in React
I’m working on a basic Todo app. I’m storing the todo items in state as an array of objects. The object key is the todo item, the value is either true(done) or false(not done). When I click a button to check off an item, I want to change the value of the todo item as well as change the style
React Testing Library does not find elements using getAllByTestId after initial render
I have a very simple component where I am trying to simulate an API call to get some movies with a slight delay. I want to write a test which tests that the movies are gathered and then rendered to screen. I am trying to use screen.getAllByTestId to do this, however it always fails. It is as if it doesn’t
How to pass a key value into the onchange handler for a select dropdown
I’m mapping an array[key,val] to dynamically create dropdowns. I want to pass the key from the select onChange handler so I can store the selected value in the correct index in the array. How do I pass the key. Answer You could do something like this: This way can be used for all types of form fields, be it input
How can we plot histogram graph with Apache Echart.js with Single bar highlighted with custom tooltips?
I look on the internet for some example of histogram with echart.js but only find this one. I want build somewhat similar to this one with single bar highlighted with custom tooltip. thanks in adavance for your help and time 🙂 Answer Can you provide the code you are using? You can change the tooltip option inside series, and customize
trying to create line down a graph in nivo at set time intervals
I’m using nivo charts to visualize some sick datasets. The example is like this, With the data simply like this, I want to really simply add in a at time 10, 14, 18 a line for when i exercise. Ideally, I’d like to be able to shade the area beneath that line for 4 hours afterwards, in a sort of
How to autoplay the next song onClick on a btn
I am in front of a problem. I am trying to create a music player. But now, I have a problem with my loading of the next music at the click of the next button. The new data is replaced in the state and in the render, but the music does not play by itself after the button is clicked.
How to use useState to display a different language
I’m trying to do a function using useState to change the languages of my website. However, I’m having an issue thinking about the logic of how can it be done since I’m newbie. 1st question: How can I use the function “handleLanguage” to change the menu language when I click in <li>. 2nd question: Which would be the best way
onChange doesn’t work when value of input clears
I have a problem in handling input’s value changing so here is my code in react,onChange works but when i clear the default value it doesn’t log anything until i do another change. I wrote console.log just for test. Answer Value is not changing because in reactjs component rerenders once state chages and using console.log on onChange does not update
React map through json object
I am having trouble finding a way to iterate through this nested JSON data. I would like to display elements into select option list. I store my data in a state after a request. I already tried: Last one gives my TypeError: Cannot read property ‘map’ of undefined. If i try to set my state to setFilterData(res.data.regions) then i can