Comments (5)
@joshhornby Hey I had a look into this. You can easily pass in the req.user object to be bootstrapped by alt.
Below is a horrid example:
// Naming convention leaves a lot to be desired
var user = req.user ? { object: req.user, authenticated: true, isWaiting: false } : { object: null, authenticated: false, isWaiting: false };
Whereas your Dashboard.jsx could be something like:
import React from 'react';
import UserStore from 'stores/UserStore';
export default class Dashboard extends React.Component {
constructor(props) {
super(props);
this.state = UserStore.getState();
}
componentDidMount() {
UserStore.listen(this._onChange);
}
componentWillUnmount() {
UserStore.unlisten(this._onChange);
}
_onChange = () => {
this.setState({
user: UserStore.getState().user
});
}
render() {
console.log(this.state.user.get('object'));
return (
<div>Welcome to the Dashboard
<div>{this.state.user.get('object').get('email')}</div>
</div>
);
}
}
We'll be using AltContainer soon hopefully so none of this listen to stores for every high level component lol
from reactgo.
@choonkending This still produces the same issue. After the intial login the user state only contains what has been set in the login action. Doing the example above doesn't work as undefined
is returned when I do props.user.get('object')
(I am already using AltContainer π )
I will see if I can reproduce this bug this weekend and get an example repo online.
from reactgo.
@joshhornby Can you also have a look at #61? This is how I got AltContainer working.
from reactgo.
Sure. I'll base my example repo off this.
Edit: On second thoughts no I'll get it working the old way and then update when the time comes!
from reactgo.
@joshhornby Closing as it's been quite a big change since then. Let me know what you think of the current redux :)
from reactgo.
Related Issues (20)
- webpack config file preload all different environment configs.
- Failed to serialize user into session when using MYSQL with Node and Passport. URGENT
- Easy deployment question HOT 4
- Postgres DB on port other than 5432 HOT 2
- New release / update changelog and publish to npm
- Remove usage of css @apply HOT 2
- Consider bundle size limits for vendor packages
- Close / Update old / rotten PRs
- Update all npm packages HOT 2
- Please re-install nodemon HOT 1
- Use hooks HOT 2
- Consider using easy-peasy on top of Redux HOT 1
- Do not bundle server application (Using Node.JS v. 9 with modules support) HOT 1
- [QUESTION] Where I can find the CI service? HOT 2
- Signup error when using CORS HOT 2
- Introducing immer
- Introducting TypeScript
- postcss-cssnext deprecated HOT 1
- Use react-router v5
- leadme νκΈ κ³΅μλ¬Έμ λ§ν¬
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactgo.