score:1
add componentwillreceiveprops()
and call the query there. it will run whenever the component receives new props. if you need to re-run the render
function with the results of the query, you may need to call forceupdate();
componentwillreceiveprops(nextprops) {
const localthis = this;
this.client.query({
query: my_query,
variables: {myvar: thevar},
}).then((result) => {
localthis.setstate({mystatevar: result.data.relevantdata});
localthis.forceupdate();
});
}
Source: stackoverflow.com
Related Query
- query not called when props are changed in Apollo client with react js
- React JS Not Completely Updating View When Render Is Called With New Props
- Next/React-Apollo: React props not hooked up to apollo cache when query comes from getInitialProps
- React shouldComponentUpdate() is called even when props or state for that component did not change
- React memo keeps rendering when props have not changed
- Apollo client 2 with React couldn't make query
- Routes are not navigating when React v15.5 setup with react-redux v5 is
- onCompleted handler not firing with Apollo Client Query
- Component not mounted when setState called in arrow function in React with ES2016
- React - change state when props are changed
- Testing Apollo Query with React Hook Client
- React component `this` is not defined when handlers are called
- React Components are not refreshing when the prop data is changed
- How to redirect to a url along with a component in react such that props passed to the component are not lost
- "Objects are not valid as a React child" when trying to redirect with valid/no authentication
- React component not rerendring when state is changed with Redux
- I AM HAVING ERROR WHEN TRYING TO MAP A DATA IN REACT . Objects are not valid as a React child (found: object with keys {children}), How do i solve it?
- React - history.push is not working- when only query is changed
- How to send react app to client with express when you have routes that are authenticated and some that are not?
- React not updating its state when come back using react-router in Apollo Client
- objects are not valid as a react child (found object with keys) while passing props from one component to other
- Unable to update a list with react when its value is being changed using the hook useState function from React TypeError: map is not a function
- Actions passed as props in Redux connected component are not called when form submit is simulated during testing
- Not render when Apollo query is 'loading' - React
- Apollo Client cache doesn't update on query when variables are changing
- React wrapper component (HOC) does not re-render child component when it's props are changing
- Props values in react router render method are not updated with Firebase firestore onsnapshot realtime update
- Why are React onclick events are not firing when I wrap with a Vue application? (Without Other Libs)
- When and how to redirect with Apollo Client and React Router
- Api call with timer not firing when props are updating faster than timer is set for
More Query from same tag
- Understanding the behaviour of useEffect() and useState() hooks
- Landscape setting in Chrome is not available when using ReactToPrint
- Styling ReactSelect with CSS-in-JS
- React component does not render
- How to I remove the text inside a Text Area after submit React JS
- How do I use the excludeTimes of react-datepicker in a functional component and use the onChange?
- GeoJSON from API won't show with react-leaflet
- Make generated QR code downloadable on react project
- how to create ref in functional component in react js?
- React 'useContext' hook not re-rendering after context updates with database data
- Infinite render caused by child component taking props from parent
- Testing useContext() with react-testing-library
- React 16: access context from outside of function component
- How to fix loop Promise pending (async/await) in react
- Implementing drag&drop with react for multiple lists
- Is it posible to sync latest state in function
- How to make a loop to reuse a function
- Vis.js/React/JavaScript: Render Vis.timeline
- Change Row/Column hierarchy dynamically when using flex in ReactJs
- Getting data from the react app.js into react chart.js
- React hook dynamic name based on loop
- Scroll to a component when a button is clicked in React JSX
- React hooks cause unintentional re-render
- How to use onPress in component React Native Maps
- query not called when props are changed in Apollo client with react js
- React Nextjs routing passing Redux Store
- Prevent Caching on a specific RTK Query Endpoint
- Simple reducer combining generating issues
- Getting Uncaught TypeError: Cannot set properties of null while using useRef
- How to call a function in a Reusable component in React