react-router服务器端重定向

时间:2016-06-03 10:17:33

标签: javascript redirect reactjs react-router

如何在服务器端重定向,而componentWillMount?

  1. 用户类型/ event / 123 / something-here
  2. 如果需要重定向,需要将其重定向到/ event / 123 / -true-url
  3.    static contextTypes = {
          router: React.PropTypes.any
        };
    
        static needs = [
            EventActions.getEvent
        ];
    
        componentWillMount() {
          if(this.props.event.get('redirect')) {
            let path = this.props.event.get('redirect');
            this.context.router.push(this.props.event.get('redirect'));
            //console.log(this.context);
          }
        }
    

    什么都没发生。没有警告。网址是相对的。 子组件开始渲染。这个组件是容器。

0 个答案:

没有答案