Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Updated Readme to clarify nested route sequences #286

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ To show a `Fragment` when no other `Fragment`s match a route, use `<Fragment for
</div>
</Fragment>
```

...React will render:

```html
Expand All @@ -311,6 +310,28 @@ To show a `Fragment` when no other `Fragment`s match a route, use `<Fragment for
</div>
```

If you want to use nested fragments for complex navigation patterns, you should remember to put the most generic route at the end of your jsx. If you do not follow this advice your route will just get matched to the first matching route.
Internally the Fragments get converted into default Route objects the sequence is important:
e.G. '/users/:id' -> would get mapped to '/users/' -> render UserManagement.

To solve this little issue just rearrange the sequences like that:

```jsx
<Fragment forRoute="/admin">
<React.Fragment>
<Fragment forRoute="/users/:id/requests">
<AbsenceRequests />
</Fragment>
<Fragment forRoute="/users/:id">
<UserManagementDetails />
</Fragment>
<Fragment forRoute="/users">
<UserManagement />
</Fragment>
</React.Fragment>
</Fragment>
```

`<Fragment>` makes basic component-per-page navigation easy:

```jsx
Expand Down