Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add the example for useContext hook
  • Loading branch information
sosukesuzuki committed Jan 26, 2019
commit 71f4e9408f4238174ab8856e6ebc0f0f78bf4bf1
13 changes: 13 additions & 0 deletions playground/src/hooks/use-theme-context.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';
import ThemeContext from '../context/theme-context';

interface ThemedButtonProps {}

export default function ThemeToggleButton(props: ThemedButtonProps) {
const { theme, toggleTheme } = React.useContext(ThemeContext);
return (
<button onClick={toggleTheme} style={theme} >
Toggle Theme
</button>
);
}