You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you start with initial value of pageOne, change it to pageTwo and then try to change it back to pageOne component is not re-rendered / no update happens. However toggling between pageTwo and pageThree works fine. You can check this in codesandbox mentioned above.
importReactfrom"react";import{useRouterValue,useRouterSelector,push}from"./routerState";exportdefaultfunctionApp(){// This Works// const { page } = useRouterValue();// This Doesn't workconstpage=useRouterSelector(s=>s.page);return(<div><buttononClick={()=>push("pageOne")}>Page One</button><buttononClick={()=>push("pageTwo")}>Page Two</button><buttononClick={()=>push("pageThree")}>Page Three</button>{page==="pageOne"&&<h1>Page One</h1>}{page==="pageTwo"&&<h1>Page Two</h1>}{page==="pageThree"&&<h1>Page Three</h1>}</div>);}
The text was updated successfully, but these errors were encountered:
xzilja
changed the title
[bug] useSelector won't trigger update if value changes to initial one
[bug] useSelector won't trigger update if value is changed back to initial one
Jun 30, 2020
Was playing around with
useSelector
and came across one problem. Assuming use case below (also available at https://codesandbox.io/s/zealous-visvesvaraya-tvvn7?file=/src/App.tsx)If you start with initial value of
pageOne
, change it topageTwo
and then try to change it back topageOne
component is not re-rendered / no update happens. However toggling betweenpageTwo
andpageThree
works fine. You can check this in codesandbox mentioned above.State
Component
The text was updated successfully, but these errors were encountered: