I’m trying to implement a follow and unfollow button in my app. I’ve been trying to update it in the state, but when I click the follow button it changes all the user’s buttons (not only the one clicked). Now I’m a bit confused on how to show unfollow button if the user is already foll…
Tag: reactjs
How can I conditionally map multiple arrays with if statements after fetching an array of objects? (React)
This is all in Prescriptions.js I am fetching a bunch of prescription drugs from my api. After that’s done, I want to make a category array based on drug.class and render it down there. If that category already exists, then push the drug into it’s category’s array, if it doesn’t, make …
Material-UI popover triggered by onMouseOver is blocking onClick event of button – React.js
This is Header.js where I have the button <ReactSvg>, inside <IconButton> when you click it, it will change the page theme with the switchTheme() function. When you hover over the button it also has a popover where it declares the function of the button (ex. switch theme). For some reason I hover …
react context is giving undefined object
In my react application I am trying to use context api. In my component I am importing the context but it is giving error that object can not destructure the property. I am trying to implement cart functionality in my app. I am using hooks. ImgContext.js ImageGrid.js Answer You are not providing a a default v…
Passing an onClick function from parent to child, automatically calls it on page render
I passed this function to a child component of mine: through this: And in my child component, I call it here: When the page renders, the modal (called from setMShowEditQuestion(true)) is already opened, and the console log is already flooded from the console.log(question) even if I haven’t clicked anyth…
Which is fastest – Pure Component, Functional Component, Class Component? [React.js] [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I am pretty novice in React and trying to learn up. In a recent interview the interviewer as…
Apply filters to a list and show data
Front-end: After return(): Service.js: Controller.js: So, this page of my web-app serves to show a list of all the companies saved in my database. I created a filter that allows you to show only those of a certain type, via findByType. I would like to insert other filters such as: findByRevenue, findByEmploye…
I get an Error from React: Maximum update depth exceeded
I wrote my codes and i think everything is right but i get an error from react.js Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops. App.js: User…
How to update nested array in React state?
I am trying to update my state so that a nested array gets emptied but the rest of the state stays the same. My state object looks like: And I the closest I get to working is: The console warning I get with this approach is: But how else is this possible? Many thanks 🙂 Answer The first problem I
dispatching actions on every render
I am dispatching action addProducts on every mount of the ProductList component whereas i want to dispatch the action one timeusing useEffect hook and store the data in the redux and then use it. Below are my actions file and ProductList component file. actions.js file ProductList.js component file Answer You…