preact-mobx
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

Preact MobX

Simple observer decorator for using Preact components with MobX

Install

yarn add preact-mobx

Usage

import { h, Component } from 'preact';
import { observable, action, useStrict } from 'mobx';
import { observer } from 'preact-mobx';
 
useStrict(true);
 
@observer
class AppComponent extends Component<any, any> {
    @observable
    public name: string;
 
    @action
    public updateName = (evt: Event) => {
        this.name = (evt.target as HTMLInputElement).value;
    }
 
    public render() {
        return <div>
            <h1>Hello, {this.name}</h1>
            <input placeholder="Name" value={this.name} onInput={this.updateName} />
        </div>
    }
}

Readme

Keywords

none

Package Sidebar

Install

npm i preact-mobx

Weekly Downloads

4

Version

0.1.4

License

MIT

Last publish

Collaborators

  • vuex