Skip to content

[feature/howto] how to cache route? #166

Description

@mainendra
  • is there a way we can cache the route / component for faster render and restore scroll position when navigating back, etc?
  • what if we want to cache component but also want to update it if it rely on some global state?

Activity

  1. molefrog commented on Jan 12, 2021

    @molefrog
    Owner

    There should be a way to do that in React, I'm confident in that. But it most def won't be available as something included in wouter, as it is against its core philosophy: to the keep the code as minimal as possible.

    Remember, Routes are just components that conditionally render or don't render its content. That's it. I would suggest to figure out the scroll restore first using plain components without routes. It should be easy to connect it to the router afterwards.

    Regarding caching, I'm not fully sure how you're planning to cache a component in React. At least, I haven't met applications where it is done, perphaps because React is fast enough to handle re-renders. I guess, it's better to invest in optimizations such as https://reactjs.org/docs/react-api.html#reactmemo

  2. mainendra commented on Jan 12, 2021

    @mainendra
    Author

    @molefrog - Make sense. We should keep it as minimal as possible. That is the USP and that's what I like about it 🙂
    Closing this ticket. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions