Skip to content

Tag: reactjs

How to find an element by id in nested arrays

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…

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 …

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:

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…