Skip to content

Instantly share code, notes, and snippets.

@alex-cory
Created September 18, 2017 08:16
Show Gist options
  • Save alex-cory/775a73bd61375f1810adcfbc140100dc to your computer and use it in GitHub Desktop.
Save alex-cory/775a73bd61375f1810adcfbc140100dc to your computer and use it in GitHub Desktop.
Making @observer better
import { observer as observe, inject } from 'mobx'
import { withRouter } from 'react-router'
import React, { Component } from 'react'
// I wonder if this works
const observer = stores => Component => withRouter(inject(...stores)(observe(Component)))
@observer('store')
class MyComponent extends Component {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment