React hook for getting Styled Components theme values.
npm i use-styled-theme || yarn add use-styled-theme
import React from 'react'
import { ThemeProvider } from "styled-components";
import useStyledTheme from 'use-styled-theme'
const Component = () => {
const { color } = useStyledTheme();
return (
<div style={{ backgroundColor: color }}>
<h1>{color}</h1>
</div>
);
};
const App = () => (
<ThemeProvider theme={{ color: "#BADA55" }}>
<Component />
</ThemeProvider>
);
Example available on Codesandbox
MIT © markoradak