score:0
Try: (using refetch)
const { data, loading, error, refetch } = useQuery(ORGANISATIONS_QUERY);
const useGetOrganisations = async () => {
if (loading) {
return 'Loading...';
}
if (error) {
return `Error! ${error.message}`;
}
return dispatch({
type: 'FETCH_ORGANISATIONS',
payload: data.organizations,
});
};
Source: stackoverflow.com
Related Query
- How to combine React hooks (useContext, useEffect) with Apollo react hooks (useQuery)
- How to use setTimeout() along with React Hooks useEffect and setState?
- How to test React useEffect hooks with jasmine and enzyme
- React hooks pagination with useEffect - how to revert page number if request fails?
- How can I use Apollo React hooks with Storybook?
- How to Make A second API call based on the value gotten from the first. with React and useEffect hooks
- How to call loading function with React useEffect only once
- How to implement Error Boundary with React Hooks Component
- How to focus something on next render with React Hooks
- How to mock history.push with the new React Router Hooks using Jest
- How to clean up setInterval in useEffect using react hooks
- How to correctly redirect after catching authentication failure with Apollo and React
- React Hooks with React Router v4 - how do I redirect to another route?
- How to handle/chain synchronous side effects that depend on another with React hooks
- How to run a mutation on mount with React Apollo 2.1's Mutation component?
- state inside useEffect refers the initial state always with React Hooks
- How to implement componentDidMount with hooks in React to be in line with the EsLint rule "react-hooks/exhaustive-deps": "warn"?
- How to use React Hooks Context with multiple values for Providers
- How to use React Hooks with video.js?
- How to execute store.unsubscribe from useEffect using React hooks and Redux
- How to perform a server side data fetching with React Hooks
- react | redux-form | material-ui | how to combine DatePicker with my form
- Access old state to compare with new state inside useEffect react hook with custom hooks usePrevious
- How to test hooks with two useEffect statements?
- How to use static variables with react hooks
- How can ı pass function with state for react useContext
- Persistence with localStorage with useState and useContext React Hooks
- Replace of setState callback in react hook with useEffect hooks for complicated scenario not working
- How to perform authentication with React hooks and react-router
- How to use RichUtils with React Hooks
More Query from same tag
- What happens for an useEffect with the second argument is null or undefined?
- How to access a react component fiber in whatsapp web from chrome console?
- ReactJS nested looping on JSON object
- State not updating until 2nd time the form is submitted
- The development server returned response error code: 500 on a boiler plate code
- Target browser option in useBuiltIns/babel polyfill
- React Hook useEffect has a missing dependency: 'dispatch'. Either include it or remove the dependency array react-hooks/exhaustive-deps
- Polyfill in create-react-app does not work
- React Redux - passing props with actions
- How Should I Dispatch Actions When Using React Hooks?
- Getting ERR! missing script: start on <npm start> command
- Can't figure out how to change State in reducer without causing a mutation
- How to pass handlSubmit and handleChange functions from Parent to Child in React
- How to show dinamically a react component
- Row click react.js
- Code is moving on before my fetch is completed
- Getting empty data object from my form react-hook-form
- React-ChartJS-2 Disappearing Chart when using Labels
- Response Isn't Converting To JSON
- Firebase Auth v9: Object(...) is not a function
- How to use React.useRef() in class component?
- ReactJS - setState of Object key in Array
- reacter router dom is not working
- React map gl with typescript
- Invoke child method before invoking child component using react ref
- How to get radio button and calender control values in react js
- How to define React Class/Function components in TypeScript (With typechecking)
- Is it possible to make react-bootstrap-pagination always show pagination controls even if the total page count is 1?
- Project Structure for a CRA React Project with React Query
- React App's Imported Object Doesn't Update Automatically On Page