0
class Recommended extends Component {
    componentDidMount() {}

    render() {
        return (
            <React.Fragment>
                <Switch>
                    <Route
                        path="/recommended/category/:categoryId"
                        component={SceneRecommendedCategory}
                        render={() => {
                            return <SceneRecommendedCategory />;
                        }}
                    />
                    <Route exact path="/recommended" component={SceneRecommendedList} />
                </Switch>
            </React.Fragment>
        );
    }
}
handleChangeCategory = categoryId => {
        const { history } = this.props;
        history.push(`/recommended/category/${categoryId}`);
    }
<Link to={`/recommended/category/${category.id}`}>A</Link>

Hi, so my problem is i can not redirect between /recommended/category/:categoryId. Url was changed from /recommended/category/1 to /recommended/category/2, but reactjs was not rendered, i can tell there is nothing change. Please help me out.

NHSon
  • 1
  • 1
  • 2
    Can you clarify why you are specifying both component and render on the Route component? – Alexander Staroselsky Jan 06 '20 at 04:15
  • @AlexanderStaroselsky Yes, that...using both `component` **and** `render`... immediately stuck out to me. NHSon, can you share the component code for `SceneRecommendedCategory`? You may need to use `componentDidUpdate` or some other prop check on the route param `categoryId` to check when it changes from `1` to `2`. – Drew Reese Jan 06 '20 at 06:50

0 Answers0