0

I am working on a reactjs application and I have a component that will provide a visualisation to represent the users. The admin will be able to select a user - and the id of the user comes back to the parent shell - but I am having issues trying to redirect the url to go to that particular user -- doesn't appear to do anything.

So in this case obj.data will contain just a number.

var UserExplorer = React.createClass({

    setParentState(obj) {
      console.log("obj", obj.data);

      Object.keys(obj).forEach((key) => {
        this.setState({
          [key]: obj[key]
        });
      });

      <Redirect push to="/user/2"/>

      //this.navigate("/user/2")
      //<Redirect to="/user/2" />
    },

    render: function () {
      var data = null;

      return (
        <div className="component-container">

              <ViewedMeChart 
                  width="250" 
                  height="250"  
                  data={data}
                  setParentState={this.setParentState} />

        </div>
      );
    }
});
The Old County
  • 89
  • 13
  • 59
  • 129

0 Answers0