i trying create reply to comments in my project, and I have some problems with adding comments to reducer, i am trying to add an reply without reloading the page. My comments looks at: It’s my reducer, now i trying write to console: I can’t think of how I can iterate through my array to add a comm…
Tag: reactjs
Calculate the percentage of an object property
I have an object, where i want to calculate the percentage and display in the maps, currently the data i am getting is a raw data in an object. Here is the object that i am receiving from backend Based on the object i want the percentage to be calculated and replaced in the respective key/value pair. It will …
How to retrieve data from a Firestore database
I am doing a project in React, where after I type a value and then click on search button, the app searches if the id exists in the database. If so, it displays the result of the search in the same page. I am having trouble assigning the value of the search and then displaying it. When I try to
How do i use fetch with a result from a fetch in the same function with sync await
the promise creates an array like this, taken from the console: which cannot be used. the code is this: at the point, the list is returned (when the useData function is used) the mapping seems to have not finished. So it returns “promise” instead of the list it should. The aim is to combine the ob…
Disabled When Lacking Input in Field in React
I have set of inputs that needs to be filled out completely. I should disable the submit button when its not complete. Its working fine until I decided to erase and fill it out again. It never disables. What would be the proper and correct way to do this? Is there a better way to do this? CLICK HERE Answer
React Simple Compont is not rendering inside the browser
Hi have create a sample function and called inside the RenderDOM But seeing in the brower end the output is not showing Do anyone have any suggestion What is wrong with this code Answer React component needs to be in capitalizing first letter: You can see it in the log error: So change it to:
useEffect doesn’t fire when data change
I created a table with filter. every thing worked well. Later on, I wanted to change the filters from material ui to Core ui. I created one filter and tried to test it before moving. But it didn’t work. The problem that useEffect doesn’t fire no matter what. I even tried to put variable x and incr…
Change game without changing the games added before
Im consuming a json file with the some games. I want to add a new Game and the chooseGameToAdd() choose what game will be without changing the games added before Json file: Code: Answer The problem is you do not have an id in the JSON objects, but you use item.id as the key. If you were actually using typescr…
React-router get optional query parameter
i have been looking into some examples on stack overflow for defining optional query params in react-router and finally found out that it can be done like so at next step i want to retrive the query param that is “journyeId” if it is there, so i tried with but that doesn’t seems to work, wha…
fetching data in react returns an empty array
i’m fetching data from my backend api and setting the data to my state but it’s returning an empty array and idk why this happening even though in other components it works just fine this is my code : Answer I was just missing a return in the .map function