Fork me on GitHub
#om
<
2017-03-24
>
danielstockton07:03:23

I'm trying to use :shared-fn to share the current user across all components. Problem is, it isn't updated on login/logout without a refresh. Is there a way to 'refresh' the reconciler?

danielstockton08:03:50

Login and logout are the only times when this is a problem, but i'd rather not trigger a page reload if I can avoid it.

danielstockton09:03:39

Doesn't seem to work 😞 I'm trying to call it in componentDidUpdate of my Wrapper component if the user props change..

danielstockton09:03:36

It does go through my :shared-fn.

danielstockton16:03:44

It seems like force-root-render! does not force re-rendering every component, it still diffs the props. This seemed to be the problem earlier ^^, I was looking for a method of refreshing the entire UI tree.

tony.kay17:03:56

It is alraedy built-in

tony.kay17:03:06

that is what :ui/react-key on the root is for

tony.kay17:03:22

you have to change the key on the root element, or React won't really re-render everything

tony.kay17:03:54

oh, sorry, that comment was an untangled-ism, but the fact is true for React in general

tony.kay17:03:39

If the React key changes on an element, then React doesn't even look at diffs: it just re-renders the whole UI (sub)tree

tony.kay17:03:22

For your use-case, you might want to use a link query instead of shared

tony.kay17:03:40

cause that way you could trigger re-renders on components that ask for that "root" data

tony.kay17:03:47

through the normal Om mechanisms