Next.js: Add example with mobx

Created on 3 Jan 2017  路  13Comments  路  Source: vercel/next.js

Some people have had issues using it, so it'd be great to have an example. It's a bit more involved than others since it requires decorator support, so it'll impose a .babelrc

Most helpful comment

Is this so hard to add decorators?
I only put a .babelrc and it just worked.

{
  "presets": [
    "next/babel"
  ],
  "plugins": [
    "transform-decorators-legacy"
  ]
}

All 13 comments

@rauchg I hope there's a way to use mobx without decorators too.

Yes it is possible to use it without decorators, I have an example here:

https://github.com/fdidron/mobx-next-example | https://mobx-next.now.sh/

(It includes a lot of other stuff I discovered when using next for the first time :D, maybe a simpler example would be more suited)

EDIT: Mobx documentation has a very interesting part on how NOT to use decorators : http://mobxjs.github.io/mobx/best/decorators.html

@fdidron the question is how many of mobx users decorators or not.
If most of the users use decorators, we need to use decorators in our example.

Yes it a majority that uses it, I did a poll a while back if I remember correctly it was 70-ish percent, so including decorators as example would be greatly appreciated!

Btw, mobx-state-tree might be very interesting in the future for next as well, as it provides a unified way how to serialize and transfer state (and it is decorator free ;-))

@mweststrate thanks. 70% is the majority :)
I think then we should add an example with a decorator.

@arunoda I'm very happy to help on the example using decorators. Would it make sense to simply port the "with-redux" example ?

@fdidron yeah! That'd be awesome.

Is this so hard to add decorators?
I only put a .babelrc and it just worked.

{
  "presets": [
    "next/babel"
  ],
  "plugins": [
    "transform-decorators-legacy"
  ]
}

@cncolder Nope. It's not that hard :)

simple example using decorators.
https://github.com/aranajhonny/next-with-mobx
demo --> https://next-with-mobx-bnmkseetwa.now.sh/

@aranajhonny Very simple, thank you!

@arunoda Here is a PR #676

We got the PR.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

formula349 picture formula349  路  3Comments

lixiaoyan picture lixiaoyan  路  3Comments

rauchg picture rauchg  路  3Comments

sospedra picture sospedra  路  3Comments

havefive picture havefive  路  3Comments