graphql-react
Version:
A GraphQL client for React using modern context and hooks APIs that’s lightweight (< 4 kB) but powerful; the first Relay and Apollo alternative with server side rendering.
14 lines (11 loc) • 498 B
JavaScript
// @ts-check
import React from "react";
/**
* React hook to force the component to update and re-render on demand.
* @returns {() => void} Function that forces an update.
* @see [React hooks FAQ](https://reactjs.org/docs/hooks-faq.html#is-there-something-like-forceupdate).
* @see [Gotcha explanation](https://github.com/CharlesStover/use-force-update/issues/18#issuecomment-554486618).
*/
export default function useForceUpdate() {
return React.useReducer(() => Symbol(), Symbol())[1];
}