这是indexloc提供的服务,不要输入任何密码
Skip to content

feat(boilerplate, cli): remove mobx-state-tree from the ignite boilerplate completely #2960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 29, 2025

Conversation

markrickert
Copy link
Member

@markrickert markrickert commented May 29, 2025

Description

There's been internal discussion for a while about going state-agnostic with ignite because we hear so often that mobx is a barrier to adopting ignite. Even though there's a way to strip it out in the current cli, it just serves to add complexity without a whole lot of benefit anymore.

@jamonholmgren Even replied to a reddit thread about removing MST from ignite.

Screenshot 2025-05-28 at 8 30 06 PM

So here we are. It's gone. All traces of it 😬 I rewrote the current stores/models in pure react context and stripped everything relating to state management out.


This PR completely removes all state management options from ignite-cli:

  • strips out mobx, mobx-state-tree, mobx-react-lite, & the reactotron plugin
  • removes model generators and tests associated with them
  • rewrites the AuthStore as a react context provider that uses mmvv hooks to persist the data
  • rewrites the EpisodeStore and Episode model as a typed react context provider
  • updates the documentation relating to "models" and adds some new content around these new context providers we're using instead of mobx

Checklist

  • README.md and other relevant documentation has been updated with my changes
  • I have manually tested this, including by generating a new app locally (see docs).

Future

  • Create an ignite cookbook recipe for using mobx state tree in ignite (if anyone will want it... they could just look at this PR and reverse it)

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Removes MobX-State-Tree from the Ignite boilerplate and replaces it with React Context providers for authentication and episode state management.

  • Strips out all MST-related models, helpers, and Reactotron MST plugins
  • Introduces AuthContext and EpisodeContext providers and hooks
  • Updates screens and navigators to use the new context APIs

Reviewed Changes

Copilot reviewed 63 out of 63 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
boilerplate/app/screens/LoginScreen.tsx Replaced MobX observer and useStores with useAuth
boilerplate/app/screens/DemoPodcastListScreen.tsx Switched from useStores to useEpisodes, refactored EpisodeCard
boilerplate/app/screens/DemoDebugScreen.tsx Replaced useStores with useAuth
boilerplate/app/navigators/DemoNavigator.tsx Wrapped Tab.Navigator with EpisodeProvider
boilerplate/app/navigators/AppNavigator.tsx Removed MST observer and useStores, now uses useAuth
boilerplate/app/context/AuthContext.tsx Added AuthProvider and useAuth hook
boilerplate/app/context/EpisodeContext.tsx Added EpisodeProvider and useEpisodes hook
boilerplate/app/models Removed all MobX-State-Tree model files
boilerplate/app/app.tsx Wrapped AppNavigator with AuthProvider, removed store rehydration
README.md Removed MobX references from documentation
Comments suppressed due to low confidence (3)

boilerplate/app/context/EpisodeContext.tsx:11

  • Add unit tests for EpisodeContext to verify behavior of fetchEpisodes, toggleFavorite, hasFavorite, and episodesForList under different scenarios.
import {

boilerplate/app/context/AuthContext.tsx:1

  • Add unit tests for AuthContext to cover setAuthEmail, setAuthToken, logout, and the validationError logic.
import {

README.md:64

  • [nitpick] Consider adding a section to the README with usage examples for the new AuthContext and EpisodeContext providers to guide users migrating from MST.
| MobX-React-Lite                  | React Integration    | v3      | Re-render React performantly                   |

@markrickert markrickert force-pushed the mrickert/expo53/mst-removal branch from e3ee03f to 1eca65b Compare May 29, 2025 02:49
- `AuthContext`: This is a basic context that provides the demo app with a way to manage simple authentication state. We persist the data using MMKV hooks in this context provider. The app can consume the AuthContext wih the `useAuth` hook.
- `EpisodeContext`: This context provides the demo app with a way to manage the list of episodes in the demo podcast screen. This context provides a `useEpisodes` hook that can be used to fetch the episodes and manage the state of the list.

## State management solutions
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice - I think this is a really great way to summarize the options.

Copy link
Contributor

@coolsoftwaretyler coolsoftwaretyler left a comment

Choose a reason for hiding this comment

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

Hey @markrickert - I know this is still in draft and there's some CI to fix, but I had a special interest in this one, haha.

Took a look at the code changes and I think it all makes sense. I had a few suggestions, nothing that I would block on.

I pulled this branch, built Ignite locally, and spun up a new app with all the default settings. Ran it on Android and iOS and tapped around with no issues. I think we'll want to have other people test other setup configurations to make sure we didn't miss anything, but I think this is the right direction.

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.

This is tremendous work, @markrickert! I do have quite a few tweaks, but nothing that is particularly intense. Let me know if you want to discuss any of them.

Copy link
Contributor

@Jpoliachik Jpoliachik left a comment

Choose a reason for hiding this comment

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

Good work!!
Nice to see how much this simplified the template code

export interface AuthProviderProps {}

export const AuthProvider: FC<PropsWithChildren<AuthProviderProps>> = ({ children }) => {
const [authToken, setAuthToken] = useMMKVString("AuthProvider.authToken")
Copy link
Contributor

Choose a reason for hiding this comment

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

I love this as a simple way to get persistence

markrickert and others added 11 commits May 29, 2025 16:16
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Tyler Scott Williams <tyler@coolsoftware.dev>
Co-authored-by: Jamon Holmgren <code@jamon.dev>
Co-authored-by: Jamon Holmgren <code@jamon.dev>
Co-authored-by: Jamon Holmgren <code@jamon.dev>
Co-authored-by: Jamon Holmgren <code@jamon.dev>
Co-authored-by: Jamon Holmgren <code@jamon.dev>
@markrickert markrickert force-pushed the mrickert/expo53/mst-removal branch from f8461d4 to 1c9ff60 Compare May 29, 2025 22:20
@markrickert markrickert marked this pull request as ready for review May 29, 2025 23:12
@markrickert markrickert merged commit a017cb3 into feat/expo-sdk-53 May 29, 2025
1 check passed
@markrickert markrickert deleted the mrickert/expo53/mst-removal branch May 29, 2025 23:32
@markrickert markrickert mentioned this pull request Jun 3, 2025
8 tasks
markrickert pushed a commit that referenced this pull request Jul 2, 2025
BREAKING CHANGE: adopt new architecture by default and remove legacy support (#2961 by @markrickert)

- Enable New Architecture in all new projects; legacy option removed from CLI
- Boilerplate and CLI now assume New Arch by default

feat: upgrade to Expo SDK 53 with Android edge-to-edge support (#2938 by @fpena)

- Upgrade to Expo SDK 53 and align all dependencies
- Add support for Android edge-to-edge using SystemBars
- Update app.json, jest-expo, metro.config, and related config for compatibility

feat: remove mobx-state-tree and enable bring-your-own state management (#2960 by @markrickert)

- Remove MST from boilerplate and CLI
- Replace with lightweight React Context examples for demo state
- Support persistence via useMMKVString

feat: simplify theming with refactored ThemeProvider (#2970 by @markrickert)

- Refactor useAppTheme and ThemeProvider for easier integration

fix: address compatibility issues with React 19, TypeScript, and tests (#2966, #2968 by @objecttiveSee)

- Solve TS 5.4/React 19 type issues and downgrade TS to 5.3.3
- Fix failing snapshots and metro test conditions
- Add missing ESLint plugin and clean up demo code

chore: update docs, config, and version alignment (#2964 by @frankcalise)

- Sync README, quickstart, and context docs
- Enforce node >= 20 and update linting rules across project
infinitered-circleci pushed a commit that referenced this pull request Jul 2, 2025
# [11.0.0](v10.5.3...v11.0.0) (2025-07-02)

* Ignite v11 (Expo SDK 53) (#2938) ([154d2ed](154d2ed)), closes [#2938](#2938) [#2938](#2938) [#2960](#2960) [#2970](#2970) [#2966](#2966) [#2968](#2968) [#2964](#2964)

### Bug Fixes

* **BackHandler:** switch to non-deprecated listener syntax [#2966](#2966) [skip ci] ([aeb3ee9](aeb3ee9))
* **types:** update useRef with default undefined value ([#2968](#2968)) [skip ci] ([1f7a8fe](1f7a8fe))

### BREAKING CHANGES

* adopt new architecture by default and remove legacy support (#2961 by @markrickert)

- Enable New Architecture in all new projects; legacy option removed from CLI
- Boilerplate and CLI now assume New Arch by default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants