Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How can we improve the way we generate links? #1209

Open
dmfalke opened this issue Sep 20, 2024 · 0 comments
Open

Question: How can we improve the way we generate links? #1209

dmfalke opened this issue Sep 20, 2024 · 0 comments

Comments

@dmfalke
Copy link
Member

dmfalke commented Sep 20, 2024

The following needs refinement.

Creating links within the context of a web app can be error prone. Our websites are designed as a collection of apps that are integrated into a single page application via a route configuration. In many cases, the same app code can be used under multiple routes. This can make it challenging with an app needs to navigate to different pages. It is tempting to hardcode an absolute path (relative to the SPA (single page application) root url), but this does not work well if an app is used under more than one route. It is also tempting to use ../ prefixes to make relative paths, but this does not work well when the component at different nesting levels.

Some options that come to mind:

  1. Pass a baseUrl around to allow absolute paths to be constructed. The baseUrl would be relative to the spa root url.
  2. Add React context to set a baseUrl for that component subtree. This can be used implicitly by a special link component; or it could be explicit by accessing the value via a hook, or a callback function passed to the link component.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant