I have the following data: Now I need to calculate the average difficulty and fun rates per assignment. As you can see, not every student has the same assignments. What approach is the best when starting blanco. .map()? Or better for (var i = 0; i < assignments.length; i++){//do something} methode? I assum…
Tag: reactjs
How to clean input fields after another operations in a function in React?
I have a button and 2 input field and I am sending these input field values to backend. etc doing some operations. After doing operations in addCustomer function, I want to reset input fields but it is not working. Here is the code: Here everything is working good except they are not resetting or setting to a…
Why does my React app disappear when I run it
Whenever I get data on my page, after a few seconds, my whole react app disappears as in the root div in the html is left completely empty like this <div id=”root”></div> as if there is nothing. This is happening on all my other projects too even when I create a new one, this disappear…
Using maps over template literals
so I need to print a boolean value if the given string contains [[placeholder:var3]] but the var3 will be dynamically fed from an array as belwo: I tried using map around the template literals but it is throwing me an error also tried like above eg but it checks only first value of the array, so can someone p…
Error: animal.image.map is not a function
I am currently making a shelter web app using mern stack and i am struggling to display an image from my object. i already used the map but i think it is only for array objects. so i am clueless how to get the images.url on my animal object. this is my animalSchema AnimalReducer and this is what i use
Cannot destructure property ‘chat’ of ‘_ref’ as it is undefined (firebase & react)
I have this code that runs to fetch data from a firebase collection: Basically I am fetching all the docs of collection ‘chatLists’ and seeing if an array called “users” which has two users includes the current users name who’s using the app, if they do, I return them all and all…
REACT-SELECT Color the background of my cell if a choice is selected (or just the text itself)?
I want to fill the background of my dropbox cell if a selection is made. For example Taste:Good, and the Comments: 3/4, which must be the defaut value from the match.json. The background of the cell should be in green if it’s Good . And the 3/4 cell should be in yellow. (cf image) For Availability, it w…
How to check if a twilio token is expired
I have a nextjs project and I need to verify if a twilio token is expired or not. I thought about using the library jwt-decode to decode the token and take the exp attribute from it, then compare it to the actual date. The problem is that the exp date seems to be broken because it is always in 1970.
How to catch Firebase promise in React?
I have a simple function that checks if the user has Premium access or not: I tried to catch this in various ways, but no luck, it always returns an “undefined” object. What is the correct way to get the returned Boolean value? Answer onSnapshot is meant for listening to a collection continuously,…
facing issue to store value in state and 3rd time state is not updating in react js
I am trying to get value from the radio button the problem is I can get the values but when I tried to store on my state it only updates 2 times after the 3rd time when I try to update the state it is not updating. Radio buttons code. I am trying to achieve output something like this My