4 ms·
Often, the data lives in localStorage, so it isn't really "loading". If your data needs to be fetched asynchronously, a loading state is a fine solution. Even
by joshwcomeau 7y ago
Often, the data lives in localStorage, so it isn't really "loading". If your data needs to be fetched asynchronously, a loading state is a fine solution.
Even in this case, a loading solution works just fine, but it's the exact same pattern. You'd just `return <Spinner />` instead of `return null`. You also face the same issue, if you don't wait until post-mount.
- dgb23 7y agoI personally would rather defer reading from localStorage than defer rendering a component. I don't want my components to know when and where they are rendered.