chriswolmarans / gatsby-starter-mobx-react-hooks-context-api

Gatsby MobX starter using React Hooks & Context API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gatsby MobX starter using React Context & Hooks

Gatsby + MobX (mobx-state-tree) + TypeScript starter + (React Context & Hooks).

Why? Because Gatsby is excellent also for React apps (not just static sites).

Features

MobX (mobx-state-tree) & React Context with a single Root model to attach every other model onto it, so we have multiple global models in order to better separate our different concerns (or you can have multiple contexts, each for own segment of the app).

See: src/models/Root.ts

With the use of React Context and Hooks, this is simple and scalable. (e.g Made a custom hook called useMst that you can use to destructure the store or stores that you need within a given application components) - See Mobx React's recipes context and Impulse's react-hooks-mobx-state-tree.

This starter was inspired by ueno-gatsby-starter and luke-gatsby-starter with the initial Gatsby v2 + TypeScript + MobX setup from @borekb/gatsby-starter-mobx

Usage

  1. Make sure you're in a Linux-y shell (on Windows, use e.g. Git Bash or MSYS2; rm -rf and similar might be called from npm scripts).
  2. yarn
  3. yarn start

Other notable scripts (see package.json):

  • yarn build
    • (You can verify the statically generated site with e.g. npx local-web-server -d public.)
  • yarn tsc
  • yarn lint
  • yarn prettier
  • yarn test or yarn test --watch

About

Gatsby MobX starter using React Hooks & Context API


Languages

Language:TypeScript 91.7%Language:JavaScript 8.3%