foxhound87 / rfx-core Goto Github PK
View Code? Open in Web Editor NEWSSR Initial state auto-injection & hydrating
License: MIT License
SSR Initial state auto-injection & hydrating
License: MIT License
would you please provide a sample to work with mobx-react-router
Is it possible to upgrade react-router dependency from v3 to v4 (what should be done)?
What about mobx? Version 5 exists which has proxy functionality, but as far as I know rfx-core does not support that high mobx version too.
Is there any cons ? e.g.
const storeAuth = store.setup({
storeA,
storeB
})
const storeForm = store.setup({
storeC,
storeD
})
enviroment:
"mobx": "^3.2.2",
"mobx-react": "^4.2.2",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-router-dom": "^4.1.2",
"rfx-core": "^1.5.3"
entry:
.....
import "./stores" // init the store
const store = rehydrate()
ReactDOM.render(
<AppContainer>
<Router>
<Provider store={isProduction ? store : hotRehydrate()}>
<App />
</Provider>
</Router>
</AppContainer>,
document.getElementById('app'))
// hot reload config
if (module.hot) {
module.hot.accept(() => renderApp(App))
}
@withRouter // make react-router work
@inject('store')
@observer
export default class App extends Component {
constructor(props) {
super(props)
this.store = this.props.store.appState
}
componentDidMount() {
this.store.setDate('2017-11-11')
}
render() {
return (
<div className="App">
<div className="App-header">
<img src={img} className="App-logo" alt="logo" />
<h2>Welcome to React {this.store.dateStr}</h2>
</div>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload. {this.store.testVal}
</p>
..........
)
}
}
Store:
export default class AppState {
@observable testVal
constructor() {
this.testVal = '123'
}
}
import { store } from 'rfx-core'
import AppState from './AppState'
export default store.setup({
appState: AppState,
......
})
After updating Store
, for example, change this.testVal = '123'
to this.testVal = '1234'
, the log shows Store has changed, but the UI not updated.
Here is the sample project, would you please help to check?
https://github.com/njleonzhang/my-react-starter
Currently it says 2.5 || 3.
I found "rfx-core" because of react-mobx-react-router4-boilerplate, I think I have done the same thing, but I still can not make mobx store hot reload.
my project is ts-react
window.__STORE = $store.set(JSON.parse(dehydrate(window.__STORE)));
If I have a Date object in Store. then Json.stringify and parse can not handle Date properly, in this scenario, the hotreload
can not work.
JSON.stringify({a: new Date()}) ----> "{"a":"2017-08-04T08:08:54.564Z"}"
JSON.parse('{"a":"2017-08-04T08:08:54.564Z"}') ----> Object {a: "2017-08-04T08:08:54.564Z"}
the a is not a Date now, any operation to it will cause exception.
Hi,
Is there any way to call a store's method from another store? For instance, I would like to init app after user has logged in. In user store's login callback, I would like to call app stores init function.
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.