fix(cookbook-app-react-state): migrate routing to Fusion route DSL - #5229
Merged
Conversation
🦋 Changeset detectedLatest commit: 2c98883 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the app-react-state cookbook from a hand-authored RouteObject[] tree to the Fusion route DSL (layout/index/route) to align with the other routing-based cookbooks, and fixes the sidebar active-link logic so links remain active for matching sub-routes.
Changes:
- Replace inline
RouteObject[]routing insrc/Router.tsxwith a route DSL manifest (src/routes/routes.ts). - Move/align pages under
src/routes/and update imports accordingly; remove the now-unusedsrc/pages/barrel. - Fix sidebar “active link” detection to match both exact paths and
/*sub-paths.
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| cookbooks/app-react-state/src/Router.tsx | Switch router setup to consume the route DSL manifest instead of inline RouteObject[]. |
| cookbooks/app-react-state/src/routes/routes.ts | Introduce the route DSL tree (layout + index/route) as the canonical route definition. |
| cookbooks/app-react-state/src/routes/layout.tsx | Fix sidebar active-link logic to stay active on matching sub-paths. |
| cookbooks/app-react-state/src/routes/index.tsx | Add the cookbook “home” route module under the new src/routes/ structure. |
| cookbooks/app-react-state/src/routes/basics/index.tsx | Add the “basics” route module under the new src/routes/ structure. |
| cookbooks/app-react-state/src/routes/profile/index.tsx | Update import path after moving route modules under src/routes/. |
| cookbooks/app-react-state/src/routes/todos/index.tsx | Update import path after moving route modules under src/routes/. |
| cookbooks/app-react-state/src/pages/index.ts | Remove the unused pages barrel export after the routing migration. |
| .changeset/cookbook-app-react-state_route-dsl.md | Add a patch changeset for the cookbook routing migration + active-link fix. |
Migrate app-react-state's Router.tsx from a hand-written RouteObject[] tree to the layout/index/route DSL from @equinor/fusion-framework-react-router/routes, matching the pattern used by app-react-router/app-react-people/app-react-charts. Pages now live under src/routes/ (routes.ts + layout.tsx + per-route folders). Also fixes the sidebar active-link check in the layout, which previously did an exact pathname match even though routes are declared with a /* wildcard (basics/*, profile/*, todos/*) - now uses prefix matching so a link stays active on any sub-path.
odinr
force-pushed
the
fix/app-react-state-route-dsl
branch
from
August 8, 2026 16:26
5935d8c to
2c98883
Compare
Contributor
Coverage Report
File CoverageNo changed files found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why is this change needed?
app-react-state's router was the only cookbook still using a hand-writtenRouteObject[]tree, inconsistent with the file-based route DSL (layout/index/routefrom@equinor/fusion-framework-react-router/routes) already used byapp-react-router,app-react-people, andapp-react-charts. Its sidebar active-link check also had a latent bug.What is the current behavior?
src/Router.tsxbuilt aRouteObject[]array inline, importing page components from asrc/pages/barrel.src/pages/Root.tsx's sidebar marked a link active only on an exact pathname match (pathname === '/basics'), even though the route is declared with a/*wildcard (basics/*), so a link would not stay highlighted on a matching sub-path.What is the new behavior?
src/routes/routes.ts(layout('./layout.tsx', [index(...), route(...), ...])), matching theapp-react-routercookbook'ssrc/routes/layout.src/routes/(layout.tsx,index.tsx,basics/index.tsx,profile/index.tsx,todos/index.tsx); the now-unusedsrc/pages/index.tsbarrel was removed.pathname === path || pathname.startsWith(path + '/')), consistent withapp-react-router'sNavigation.tsx.What is the intended behavior or invariant?
Route definitions and page components stay under
src/routes/; sidebar links are active for their route path and any of its sub-paths.Does this PR introduce a breaking change?
No. This is a cookbook (non-published-API) internal restructuring; the rendered app behavior is unchanged apart from the active-link fix.
Impact assessment:
@equinor/fusion-framework-cookbook-app-react-state)Review guidance:
Focus on
src/routes/routes.ts(route tree) and theisActivehelper insrc/routes/layout.tsx. Verified withtsc -b --force, Biome, andfusion-lint(all clean).Related issues
None.
Checklist