Redux状态更改时不更新路由组件

时间:2020-02-06 11:32:28

标签: reactjs redux react-router-dom

如果redux中的某些内容发生更改,如何不更新Route渲染的组件?添加了一些路由示例,延迟导入的组件具有redux存储连接。

const ROUTES_OPTIONS = [
  {
    path: `${PATH_TO_SMART_ACCESS}${PATH_TO_SMART_ACCESS_VIEW}/options`,
    Component: lazy(() => import("./SmartAccessActionsOptions")),
    exact: false
  },
  {
    path: `${PATH_TO_SMART_ACCESS}${PATH_TO_SMART_ACCESS_VIEW}/:id/options/:type?`,
    Component: lazy(() => import("./SmartAccessActionsOptions")),
    exact: false
  }
];

const Routes = () => {
  return (
    <Switch>
      {ROUTES_OPTIONS.map(route => (
        <Route
          key={route.path}
          exact={route.exact}
          render={() => {
            const Component = route.Component;
            return <Component />;
          }}
        />
      ))}
    </Switch>
  );
};

0 个答案:

没有答案