Skip to content

Simple observer decorator for using Preact components with MobX

License

Notifications You must be signed in to change notification settings

VuexLtd/preact-mobx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simple observer decorator for using Preact components with MobX

Resources

License

Stars

Watchers

Forks

Packages