Created
July 21, 2020 21:16
-
-
Save mlg87/4e0e3def86e97cd79a8e2680dc424ad2 to your computer and use it in GitHub Desktop.
Using Apollo Client for global state management code samples - src/AnotherThing/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ./src/AnotherThing/index.tsx | |
import React from "react"; | |
import { BalloonPickerThatHasAllOfTheNeededLogicInItButForSomeReasonRequiresMeToPassAMutation } from "../Balloon/Picker"; | |
import { | |
useGetSelectedBalloonLocalQuery, | |
useGetBalloonsQuery, | |
useSetSelectedBalloonLocalMutation, | |
} from "../types/graphql"; | |
const AnotherThing: React.FC = () => { | |
useGetBalloonsQuery(); | |
const { data: localData } = useGetSelectedBalloonLocalQuery(); | |
const [setSelectedBalloon] = useSetSelectedBalloonLocalMutation(); | |
return ( | |
<> | |
<span> | |
You've selected the {localData?.selectedBalloon?.color} balloon! | |
</span> | |
<BalloonPickerThatHasAllOfTheNeededLogicInItButForSomeReasonRequiresMeToPassAMutation | |
onClick={setSelectedBalloon} | |
/> | |
</> | |
); | |
}; | |
export default AnotherThing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment