All Projects → Xerios → Mobx Isomorphic Starter

Xerios / Mobx Isomorphic Starter

Licence: mit
Clean isomorphic starter-kit using Mobx + React + React-router + Webpack

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Mobx Isomorphic Starter

Saas
Build your own SaaS business with SaaS boilerplate. Productive stack: React, Material-UI, Next, MobX, WebSockets, Express, Node, Mongoose, MongoDB. Written with TypeScript.
Stars: ✭ 2,720 (+4510.17%)
Mutual labels:  mongoose, mobx
Node React Ecommerce
Build ECommerce Website Like Amazon By React & Node & MongoDB
Stars: ✭ 1,080 (+1730.51%)
Mutual labels:  mongoose
Friend.ly
A social media platform with a friend recommendation engine based on personality trait extraction
Stars: ✭ 41 (-30.51%)
Mutual labels:  mongoose
Mongomem
In-memory MongoDB Server. Ideal for testing.
Stars: ✭ 51 (-13.56%)
Mutual labels:  mongoose
Mongoose Tsgen
A plug-n-play Typescript interface generator for Mongoose.
Stars: ✭ 43 (-27.12%)
Mutual labels:  mongoose
Mobx Jsonapi Store
JSON API Store for MobX
Stars: ✭ 52 (-11.86%)
Mutual labels:  mobx
Todo app open source
📱 an app to annotate tasks made with Flutter using MobX
Stars: ✭ 40 (-32.2%)
Mutual labels:  mobx
Rest Hapi
🚀 A RESTful API generator for Node.js
Stars: ✭ 1,102 (+1767.8%)
Mutual labels:  mongoose
Chatinder
Unofficial desktop messaging client for Tinder.
Stars: ✭ 55 (-6.78%)
Mutual labels:  mobx
Mongoose Transactions
Atomicity and Transactions for mongoose.
Stars: ✭ 51 (-13.56%)
Mutual labels:  mongoose
React Mobx Project
react-mobx-router开发模版
Stars: ✭ 49 (-16.95%)
Mutual labels:  mobx
Mobx React Form
Reactive MobX Form State Management
Stars: ✭ 1,031 (+1647.46%)
Mutual labels:  mobx
React Mobx Ts Antd
A simple empty project build with react、react-router、mobx、antd in typescript.
Stars: ✭ 53 (-10.17%)
Mutual labels:  mobx
Mean Angular4 Chat App
MEAN stack with Angular 4 Chat App
Stars: ✭ 41 (-30.51%)
Mutual labels:  mongoose
Wertik Js
💪 A library that powers your app with GraphQL + Rest API
Stars: ✭ 56 (-5.08%)
Mutual labels:  mongoose
Rntimerexample
📱 React Native + Mobx sample app
Stars: ✭ 40 (-32.2%)
Mutual labels:  mobx
Fclub
Vue全家桶+Koa+mongoose全栈开发的单页应用 http://wap.fulun.club
Stars: ✭ 49 (-16.95%)
Mutual labels:  mongoose
Cdfang Spider
📊 成都房协网数据分析,喜欢请点 star!
Stars: ✭ 1,063 (+1701.69%)
Mutual labels:  mongoose
React Mobx Demo
🔥 React, Mobx, and React-Router to achieve a Zhihu Daily App.
Stars: ✭ 59 (+0%)
Mutual labels:  mobx
Mongoose Fill
Virtual async fileds for mongoose.js
Stars: ✭ 57 (-3.39%)
Mutual labels:  mongoose

Isomorphic React + Mobx Starter project

The goal of this project is to provide a starting base for an mobx react project with isomorphism and SEO compabilities ( meta tags change ).

Based on nightwolfz/mobx-starter, except that it's cleaner and simplified.

Features:

  • Simplified flexible isomorphic system ( fetchData )
  • Uses Provider to inject global state into Components
  • Document title, keywords and description change integration
  • CSS and SCSS compilation
  • Hot reload for development ( page auto-refresh )
  • Battle-tested structure ( see UnityList.com )

Preview

Setting up isomorphic components is as easy as this :

@observer(["state"])
export default class Browse extends React.Component {
    // Executed on client and server ( server waits for Promise to be resolved )
    //-----------------------------------
    static fetchData({state, params}){
        state.app.title = 'Browse' // Change document title
        state.browse.data = 'Loading...' // You can add a loader for the client side rendering

        // Return a promise so that server waits until it's done before serving the page
        return new Promise((resolve)=>{
            setTimeout(() => {
                state.browse.data = 'fetchData : Hello data '+ Date.now()
                resolve()
            }, 1000);
        })
    }
    // Render
    //-----------------------------------
    render() {
        return <section>
            <h1>Browse</h1>
            <p>This is delayed page example, executed on server and client alike</p>
            <p>Try refreshing and you`ll see it takes 1 second to load this page, while changing routes on the client remains async</p>
            <p>{this.props.state.browse.data}</p>
        </section>
    }
}

How to run

    node index.js

If you want to run production build on your development machine, use cross-env ( npm install cross-env -g )

    cross-env NODE_ENV=production node ./index.js

Requirements

  • Node 6 or Node 4

Depencencies

  • Express + express-router
  • React + react-router
  • Mobx + mobx-react
  • Mongoose ( optional )
  • Babel
  • Webpack
  • Sass/SCSS loaders

Goals

I needed a fully isomorphic website where most important data is shared through out the whole application. So I made this simplified, bloatware-free code for starting a new isomorphic project.

We have one main state object that's observable and all react components decorated with @observer(['state']) have access to it ( though <Provider /> ).

All the rendering is efficiently taken care by MobX

F.A.Q.

How to add mongoose models ?

  1. Goto src/server/models
  2. Add [Name].js
  3. Goto src/helpers/database
  4. Add a new line under export const Account
  5. Require your model like this import {Account} from './src/helpers/database

How do I make my components isomorpic?

Check if you added the static fetchData({state, params, query}){ static function properly to your component.

My isomorphic component is acting strange / isn't waiting until the request has been done

Verify if your fetchData is returning a Promise and resolve is executed once all required data is fetched.

My components are not updating!

Make sure you added the @inject("state") @observer decorator to your component.

My stateless component doesn't have access to state !

You cannot use decorators on stateless components. You should instead wrap your component like this:

const MyStatelessComponent = observer(['state'],function(props, context) {
  return <p>{context.state.something} !</p>
}))

The propType of an observable array is object

Observable arrays are actually objects, so they comply to propTypes.object instead of array.

Where can I find a more complex starter ?

Check out nightwolfz's implementation ! https://github.com/nightwolfz/mobx-starter

Author

Sam Megidov

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].