react-singleton-decorator

1.0.4 • Public • Published

react-singleton-decorator

Basic

At least you need have these configs in .babelrc and install them.

// .babelrc
{
    "presets": [
      "env",
      "es2015",
      "stage-0",
      "react"
    ],
    "plugins": [
      "transform-decorators-legacy"
    ]
}

Install

npm install react-singleton-decorator --save

Use

import singleton from 'react-singleton-decorator';

@singleton
class Hello extends Component {
    render() {
        const { name } = this.props;
        return (
            <div onClick={() => this.hide()}>
                Hello, {name}!
            </div>
        )
    }
}

Hello.show({
    name: 'Lily'
});
Hello.hide();

Can use on

Alert

Modal

Message

Notification

PageLoading

Demo

npm run example

Build

npm run build

Readme

Keywords

none

Package Sidebar

Install

npm i react-singleton-decorator

Weekly Downloads

1

Version

1.0.4

License

ISC

Unpacked Size

5.23 kB

Total Files

9

Last publish

Collaborators

  • konglx