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

1.1.3 • Public • Published

Preact MobX

Simple observer decorator for using Preact components with MobX

Install

yarn add preact-mobx-observer

Usage

import { h, Component } from 'preact';
import { observable, action, useStrict } from 'mobx';
import { observer } from 'preact-mobx-observer';

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>
    }
}

/preact-mobx-observer/

    Package Sidebar

    Install

    npm i preact-mobx-observer

    Weekly Downloads

    1

    Version

    1.1.3

    License

    MIT

    Unpacked Size

    17.9 kB

    Total Files

    12

    Last publish

    Collaborators

    • magic-akari