I still learn much React JavaScript and now I can’t understand how to create this initial state. In the constructor here in the code I want to add to state by running this line: And direct after I want to add more state variables like this: The problem now is that state does not contain the first call t…
Tag: reactjs
While creating item from parent to child component, going to infinite loop in React
This is my home page and getting list data then creating List component as much as need. Then going to List component and creating list item. so creating new component using map function. I tried different ways for it but I can’t figure out. It goes infinite loop whatever I did. Home.jsx in List compone…
Moment.js formatting date field to a day earlier than it should
This is a very small little bug I’m trying to fix in my code. I have a React component with this initial state Which is used in a form like so: I’ve done console.logs to see that the Moment(new Date()).format(‘YYYY-MM-DD’) shows today’s date, as I want, but for some reason when t…
Is there a way to manipulate rendered text in react component children?
I am trying to write a component that highlights text inside it’s children recursively. What I have been able to achieve, is to highlight the text only if it’s explicitly provided in the body component, but I can’t find a way to change the text of the component’s render part. Let’…
How to disable other buttons onclick for a short period of time
i have simple quizz project where i fetch data of questions and answers my problem is when i click on one of the answers i want other buttons to be disabled because if someone keeps pressing on other options the quiz will rapidly change questions. i want to disable other answer options when i clik on the answ…
How to remove one value from a key in localstorage that has many values?
I’ve seen this question asked before but the solutions didn’t help me hence why i’ve asked it again. Currently, I am storing values into an array and that array is getting stored into localstorage. This is the object I have mapped through this and used ‘name’ as the value. I am c…
How to manage multiple states in React? [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year. This post was edited and submitted for review 10 months ago and failed to reopen the post: Or…
React Testing with history passed
Problem Statement I’m using create react app with Jest. In my test, I simply want to render out a component that needs history passed to the state before it can load. I’ve been researching and trying to get to this to work for awhile. The source I’ve been using shows how to pass the history …
JavaScript: Multiple cropping selection in one image?
PS: Is it not a research kind of question! I have been trying to do this from very long time. I am trying to make web based an image editor where user can select multiple cropping area and after selection save/download all the image area. like below. As of now I discovered two libraries 1.Cropper.JS where is …
Using QueryClientProvider in a Wrapper
I want to use a single Wrapper Component in a library im providing. The wrapper should provide stuff like Context and QueryClient. The component looks like this: When wrapping children with the Wrapper useQuery throws an error that no QueryClientProvider is set. In this case App uses the useQuery Hook from re…