score:1
Try adding an if condition inside the componentDidUpdate to check whether isActive changed or not
componentDidUpdate(prevProps){
if(prevProps.isActive !== this.props.isActive){
this.getRecipe(this.props.isActive);
}
}
this would only call the getRecipe function once the props value of isActive change
Source: stackoverflow.com
Related Query
- I have an api call that I need to invoke before the second render after it receive new props
- I have problem to render data after API fetch because I have two apis and the second api call depend on first api ID
- making second api call after getting data from the first api
- I need to call the page render after POST request
- I have a search function that only works after typing the second letter
- How is it possible that after API call and setState, some elements of the same object are accessible, while others aren't?
- How can i use the useSWR hook when my response need to do some logical operations before next dependant API call
- How to wait for AJAX response and only after that render the component?
- Wait for API call data before render react hooks
- Why does react call render function if I have not changed the reference of the state?
- Call api before first render in functional component in React.js
- How to make a second API call based on the first response?
- Why does the Sign In With Google button disappear after I render it the second time?
- I need to execute a function that will update the state right after using setState hook, but state inside function is empty?
- What is recommended way to determine if a Redux state empty array is the initial state or the result of an API call that returns an empty array?
- Why do I get a 404 for half a second when clicking a next.js `Link` that just calls an API endpoint and then navigates to the correct page?
- Why does ReactDOM.render need to call function or class components again after creating the virtual DOM?
- React is not updating the UI after receiveing data from the API call (using hooks)
- How to have a separated js file that handles the API calls in Reactjs
- Django/React App: How to have both Django URLS (for the api to send data) and React URLS (to render my components) in my web app, compatibly
- Why does React render component for the second time after setting the state to the same value?
- Change the state of an element to show an array of Components after API call
- React hook not updating after the API call
- React HOC with async call render component before the logic
- In react, what is the best way to perform an API call and redirect before Render()?
- How can I make react render the new state modifications after I have updated the state with hooks and context
- Make an API call on second render using React Hooks
- How to test api call in react component and expect the view change after success of api call?
- React Callservice script doesn't retrieve the needed information from Node.js script that makes the API call
- After the login click i am not able to render the data that i got from Login form into the HomePage
More Query from same tag
- Prevent the button click again once the dropdown menu has opened from the button React.js?
- Formik: onBlur handler on useField hook
- Unable to render content with React-Konva
- Proper way to build bootstrap modals and notifications in React JS?
- pageshow's event listener on a React component not working properly
- Which is a better to write a react component with styled-components?
- Prevent a specific attribute from rendering on DOM node in react js
- React map function returning current object plus new properties
- Serving static React app from server, crashing on refresh
- React Typescript - Math.random gives wrong result even tho min value and max value is set
- How to import and use D3-tube-map in react.js
- Style buttons with different palette colors
- Trying to extract the URL hostname from API response
- Why is my state variable not getting passed as prop to a child element?
- how to add type declaration to react-typescript project with CRA
- Typescript/React `<span>Text</span>`only writes out the text and not element
- modify and insert new object in array of objects with useState hook
- Outputting n instances of a React component
- Reactjs - How to avoid creating a new clickhandler function in each render
- What is the best and most efficient way to bind callbacks in ReactJS? In the constructor or in the render method or as a property initializer?
- React Data Grid Filter on Component
- how cache react prop to ref?
- Is it possible to have both (for instance) /posts and /posts/:id?
- How to set two properties for a React component as optional depending on another property using TypeScript?
- How do I count the number of child objects and pass the calculated index to the child object?
- Generate select option entries from variables in ReactJs
- Weird behavior of spread operator in JSX
- React GridList w/ Modal Images
- react-icons/fa fails to install: Attempted import error: 'FaStar' is not exported from 'react-icons/fa'
- Accessing data passed from NavLink after redirecting from home page to a specific page using react router