react-style-singleton
Just create a single stylesheet...
Last updated 7 years ago by kashey .
MIT · Bugs · Original npm · Tarball · package.json
$ cnpm install react-style-singleton 
SYNC missed versions from official npm registry.

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

License

MIT

Current Tags

  • 2.2.3                                ...           latest (a year ago)

10 Versions

  • 2.2.3                                ...           a year ago
  • 2.2.2                                ...           a year ago
  • 2.2.1                                ...           4 years ago
  • 2.2.0 [deprecated]           ...           4 years ago
  • 2.1.1                                ...           5 years ago
  • 2.1.0                                ...           6 years ago
  • 2.0.0                                ...           7 years ago
  • 1.1.1                                ...           7 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.1                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 9
Last Day 0
Last Week 9
Last Month 1
Dependencies (2)
Dev Dependencies (2)

Copyright 2013 - present © cnpmjs.org | Home |