Skip to content

Instantly share code, notes, and snippets.

@vman
Last active May 23, 2020 12:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vman/2045b9878934274ecfab765310f710f0 to your computer and use it in GitHub Desktop.
const [themeState, setThemeState] = useState<string>(props.teamsTheme || "default");
//Run effect once when the component loads. We will use this effect to register our Theme Changed handler.
useEffect(() => {
console.log("registerOnThemeChangeHandler useEffect fired");
props.context.sdks.microsoftTeams.teamsJs.registerOnThemeChangeHandler((theme: string) => {
console.log(`theme changed to: ${theme}`);
//Update the themeState with the new theme.
setThemeState(theme);
});
}, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment