Skip to content

Instantly share code, notes, and snippets.

@pckilgore
Last active April 21, 2021 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pckilgore/33214617d52904a04edb2c8078a50bac to your computer and use it in GitHub Desktop.
Save pckilgore/33214617d52904a04edb2c8078a50bac to your computer and use it in GitHub Desktop.
GlobalVariableContext.useSetValue();
import React from "react";
import { Button } from "react-native";
import * as GlobalVariableContext from "./config/GlobalVariableContext";
export const MyVariableSetter = () => {
const setGlobalVariable = GlobalVariableContext.useSetValue();
const myNewValue = { key: "mySettableGlobal", value: "new value" };
return (
<Button onPress={() => setGlobalVariable(myNewValue)}>
"Update a Variable"
</Button>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment