react-style-singleton
TypeScript icon, indicating that this package has built-in type declarations

2.2.1 • Public • Published

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 />);
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.2.1
    4,915,157
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.2.1
    4,915,157
  • 2.1.1
    86,330
  • 2.1.0
    11,893
  • 2.0.0
    1,686
  • 1.1.1
    4,523
  • 1.1.0
    1
  • 1.0.1
    1

Package Sidebar

Install

npm i react-style-singleton

Weekly Downloads

5,029,188

Version

2.2.1

License

MIT

Unpacked Size

18.3 kB

Total Files

27

Last publish

Collaborators

  • kashey