Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Updated mobx, store via context, and functional components #239

Merged
merged 9 commits into from
Sep 16, 2019

Conversation

bryanstearns
Copy link
Member

@bryanstearns bryanstearns commented Aug 15, 2019

I've bumped mobx to 6.x and mobs-react to 5.x, and switched to using context to provide the root store to the component hierarchy. I also converted our screens and shared components from classes to functional components.

Work-in-progress for now; I'm going to start a side project with this now and see how I like it. I've started a project with it and haven't encountered any problems, so I'm taking the "WIP" off this.

Please object if you don't like this style of things, or just point and laugh if I've gotten things grossly wrong!

I converted StorybookUIRoot to a function (in spite of the comment):

- I removed its "RN hot module must be in a class for HMR" comment; I
tested this and found no problems with hot reloading enabled, for this
component or the other components I've converted to functions.

- Googling led me to https://mobx.js.org/best/stateless-HMR.html, which
I think might also be old information; I tested the newly-functional
components with react-devtools and it's displaying their names, so I
think something must've changed with transpiling to fix that problem.

Also, the new functional components seem to trigger warnings from
the react/prop-types eslint rule. We don't put propTypes on our
components because we've got Typescript to watch our back. So, I've
turned off this eslint rule.
Copy link
Member

@jamonholmgren jamonholmgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing @bryanstearns !! I'm super stoked about this update.

Just a few changes/comments; otherwise should be ready to roll soon!

(Q. Do you see this as a patch, minor, or major release?)

…bility

We need to lock mobx at 4.x because of facebook/hermes#28 (as well as the
old version of JavaScriptCore in iOS 9 not supporting Proxies). We could
move to 5.x if we are okay with not supporting iOS 9 and Hermes, but we
don't think that's a viable path forward at this time.
@jamonholmgren jamonholmgren self-requested a review August 20, 2019 03:15
Copy link
Member

@jamonholmgren jamonholmgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I know you're testing this out on a side project, so I'll just approve and move on. Feel free to bring me back in if you need additional review.

@bryanstearns
Copy link
Member Author

@jamonholmgren I think this is more than a patch, but I'm not sure whether it qualifies for "major", sooo: minor?

@jamonholmgren jamonholmgren changed the title WIP: Updated mobx, store via context, and functional components Updated mobx, store via context, and functional components Sep 16, 2019
@jamonholmgren jamonholmgren merged commit 49d0b8a into master Sep 16, 2019
@jamonholmgren jamonholmgren deleted the context-stores-and-functional-components branch September 16, 2019 18:50
infinitered-circleci pushed a commit that referenced this pull request Sep 16, 2019
# [4.7.0](v4.6.3...v4.7.0) (2019-09-16)

### Features

* **boilerplate:** Migrated to functional components, hooks, and context ([#239](#239) by [@bryanstearns](https://github.com/bryanstearns)) ([49d0b8a](49d0b8a))
@infinitered-circleci
Copy link

🎉 This PR is included in version 4.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@thanhdevapp
Copy link

So how to passing data to props with file root-store-context, pls create example, thank you so much !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants