Skip to content

Commit

Permalink
improve context
Browse files Browse the repository at this point in the history
  • Loading branch information
kuroidoruido committed May 27, 2024
1 parent e9359fd commit 6a2200c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/markdown/06-routing-context-suspense/20-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,26 @@ export ThemeProvider() {
```

<!-- .element: class="big-code" -->

##==##

<!-- .slide: class="with-code" -->

# Use theme everywhere!

```TypeScript [1|3-6|8-11]
import { useTheme } from './useTheme';
function ShowColorTheme() {
const { theme } = useTheme();
return <p>{theme}</p>
}
function ThemeSwitcher() {
const { theme, setTheme } = useTheme();
const nextTheme = theme === 'light' ? 'dark' : 'light';
return <button onClick={() => setTheme(nextTheme)}>Active {nextTheme}</button>;
}
```

<!-- .element: class="big-code" -->

0 comments on commit 6a2200c

Please sign in to comment.