Git Product home page Git Product logo

mobx-isomorphic-starter's People

Contributors

jlipschitz avatar xerios avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mobx-isomorphic-starter's Issues

How to support mobx @actions

Is there a way to handle mobx actions with this setup? Right now when I see my store I can only spot my observables. When I try access my actions on the store they are undefined.

PS Awesome project. This starter has been a huge help for getting my app bootstrapped. Thank you.

How to fetchData in sequence while the first one is asynchronously

If there is a fetchData in App.jsx, and there is another fetchData in About.jsx

In App.jsx

@action static fetchData({state}){
  setTimeout(() => {
    console.log('a')
  }, 1000)
}

In About.jsx

@action static fetchData({state}){
    console.log('b')
    state.app.title = 'About'
}

In this situation, it will console 'b' first, and 'a' next.
But I want to console 'a' first, and 'b' next.

Really hope to get your help,thx~

NewBie - Need help to create store

Hi,

I'm pretty new to React, and MobX. I found this starter-project, every so clear and i really like it.

I trying to create some small thing to learn like a Timer.

I created 2 file

/src/client/containers/pages/Timer/store.js

import { observable, action, autorun } from 'mobx';

class TimerStore {
  @observable counter = 0;
}

const store = new TimerStore;

export default store;

/src/client/containers/pages/Timer/Timer.js

import React from 'react'
import { inject, observer } from 'mobx-react'

@observer(["state","store"])
export default class Timer extends React.Component {
    static fetchData({state, store}){
        state.app.title = 'Timer'
    }
    render() {
        return <section>
            <h1>Timer</h1>
            <p>{this.props.store.timerStore.counter}</p>
        </section>
    }
}

/src/client/routes.js
Add a new route

<Route path="timer" getComponent={requireAsync('Timer/Timer')}/>

Import store to client
/src/client/index.js

...

import { store as timerStore } from './containers/pages/Timer/store'

// Import our styles
require('./assets/css/index.scss')

// Initialize stores & inject server-side state into front-end
const state = createState(window.__STATE)
const store = {timerStore}

...

I got this error from Browser
400: An error has occured : TypeError: Cannot read property 'counter' of undefined

And this error from console
[mobx] An uncaught exception occurred while calculating your computed value, autorun or transformer. Or inside the render() method of an observer based React component. These functions should never throw exceptions as MobX will not always be able to recover from them. Please fix the error reported after this message or enable 'Pause on (caught) exceptions' in your debugger to find the root cause. In: 'Timer#0.render()'. For more details see https://github.com/mobxjs/mobx/issues/462

What did i do wrong and how to make it right. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.