Reactjs 组件安装有趣的问题

Reactjs 组件安装有趣的问题,reactjs,Reactjs,我有以下代码 componentDidMount() { if (this.props && this.props.match && this.props.match.params.code) { console.dir("mount1"); this._handleCode(this.props.match.params.code); } else { c

我有以下代码

  componentDidMount() {
        if (this.props && this.props.match && this.props.match.params.code) {
            console.dir("mount1");
            this._handleCode(this.props.match.params.code);
        } else {
            console.dir("mount2");
            this.setState({loading: false});
        }
    }
为什么当url参数中有代码时,mount2会被打印出来,而mount1会被打印出来?ex./订阅组/测试

 <ProtectedRoute path="/subscriptioncode/:code" component={SubscriptionCodeActivate}/>

const ProtectedRoute = ({
                                   path,
                                   component: Component,
                                   render,
                                   ...rest
                               }) => {
    return (
        <Route
            path={path}
            {...rest}
            render={props => {
                if (Utils.isAuthenticated()) {
                    return Component ? <Component {...props} /> : render(props);
                } else {
                    return <Redirect to={`/login?redirect=${props.location.pathname}`} />;
                }
            }}
        />
    );
};

const ProtectedRoute=({
路径
组件:组件,
提供,
休息
}) => {
返回(
{
如果(Utils.isAuthenticated()){
返回组件?:渲染(道具);
}否则{
返回;
}
}}
/>
);
};

如何实例化组件?i、 e.你能告诉我们你的路线是什么样的吗?见上文@IsmaelPadillaw这个返回组件是什么渲染(道具)?如果isAuthenticated()返回true,为什么不直接返回组件呢?