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

WIP: Documentation #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jonathanglasmeyer
Copy link
Collaborator

I started working on documentation of this library's design. Of course this needs good review, since i'm just trying to make sense of this by myself and have not written anything of it 😅. It's also totally not done, this just tracks the WIP.

The `RouterContext` ([RR docs](https://github.com/reactjs/react-router/blob/master/docs/API.md#routercontext)) renders the component tree for a given router state and supplies the `router` object on the [context](https://facebook.github.io/react/docs/context.html). Supplying a custom one via the `Router`'s [`render`](https://github.com/reactjs/react-router/blob/master/docs/API.md#renderprops) property is the crucial integration point of React Router and this library.

Whereas RR's `RouterContext` "just" renders the component tree given the props of `location`, `routes`, `params` and `components`, this library's `RouterContext` does more: **it holds state of navigation** (`navigationState`) **and the state of the navigation tree** (`navigationTree`) **in `this.state`.** When it receives new props ( = a navigation action has been performed), the new state and tree is calculated in [`componentWillReceiveProps`](https://facebook.github.io/react/docs/component-specs.html#updating-componentwillreceiveprops) (no additional render is performed when using `this.setState` in this hook). The next `navigationState` is calculated by **using the `reducer` defined for the given route**. (TODO: Question: i don't fully understand why it's taken from `nextState.reducer` here?)

Copy link
Owner

@jmurzy jmurzy Jun 12, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that one can customize the default reducers used by <Route> and its siblings. It's used by the built in reducers to run a custom reducer to create their own navigation subtree. We would probably change that API later as it doesn't allow serialization—maybe a reducerRegistry similar to how I did it for transitionRegistry.

🍺

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants