Package Exports
- react-style-singleton
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-style-singleton) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
react-style-singleton
300b with all dependencies, minified and gzipped
Creates a style component with internal tracker.
- Adds styles to the browser on the first instance mount.
- Removes after the last instance unmount.
- Thus helps you deliver styles you need to the customer, and clean up later.
- Is not server-side rendering compatible!
API
Component
import {styleSingleton} from 'react-style-singleton'
const Style = styleSingleton();
export const App = () => (
<Style styles={'body {color:red}'} />
);
Hook
import {styleHookSingleton} from 'react-style-singleton';
const useStyle = styleHookSingleton();
const useAnotherStyle = styleHookSingleton();
export const App = () => {
useStyle('div {color:red}');
useAnotherStyle('body { background-color:red }');
return (<div />);
}