1.0.2 • Published 7 years ago

mobx-react-autorun v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

mobx-react-autorun

A small react HOC to run a mobx autorun function when a component mounts, and dispose of it when the component will unmount.

import React from "react"
import { observer } from "mobx-react"
import autorunner from "mobx-react-autorun"

@autorunner @observer
export default class MyComponent extends React.Component {

  autorunner = () => {
    // this function will run like any normal mobx autorun function,
    // so it will automatically react to changes in your
    // observables. Just remember to make the component an observer!
  }

  render() {
    return (
      <div>
        Hello world
      </div>
    )
  }

}