Created
October 14, 2021 12:15
-
-
Save akinogu/5beabba6d1565f0977d37afe2c16b28d to your computer and use it in GitHub Desktop.
[styled-components]theme
This file contains 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
import { useEffect } from 'react' | |
import styled from 'styled-components' | |
import { useTheme } from './util/Theme' | |
const Text = styled.div` | |
color: ${p => p.theme.color}; | |
` | |
const App = () => { | |
const { setColor } = useTheme() | |
// APIなどからスタイルを取得した後にsetColorに値を渡す | |
useEffect(() => setColor('red'), [setColor]) | |
return ( | |
<Text>Theme sample</Text> | |
) | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment