xerios / mobx-isomorphic-starter Goto Github PK
View Code? Open in Web Editor NEWClean isomorphic starter-kit using Mobx + React + React-router + Webpack
License: MIT License
Clean isomorphic starter-kit using Mobx + React + React-router + Webpack
License: MIT License
like react-router's onEnter, you can have 'replace'
how to achieve that in this project?
what is the difference?
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.
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~
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.