ComponentDidMount called multiple times

前端 未结 1 1939
醉梦人生
醉梦人生 2021-01-20 01:36

I built a HOC to use on protected routes in my app. It takes in the component that should be rendered at the route, checks if the user is authenticated, and then renders th

1条回答
  •  执笔经年
    2021-01-20 02:29

    By calling RequireAuth(Component) in render, you are decorating Component with your HOC in every render call, making that each render returns a new Component each render.

    You should decorate Group, CreateGroup and GroupsMenu with RequireAuth, before exporting them. Just as you would with react-redux's connect.

    0 讨论(0)
提交回复
热议问题