GithubHelp home page GithubHelp logo

Comments (5)

choonkending avatar choonkending commented on May 3, 2024

@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.

joshhornby avatar joshhornby commented on May 3, 2024

@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.

choonkending avatar choonkending commented on May 3, 2024

@joshhornby Can you also have a look at #61? This is how I got AltContainer working.

from reactgo.

joshhornby avatar joshhornby commented on May 3, 2024

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.

choonkending avatar choonkending commented on May 3, 2024

@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)

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.