Skip to content

Merge next into master.#13

Merged
10xjs merged 16 commits intomasterfrom
next
Dec 23, 2016
Merged

Merge next into master.#13
10xjs merged 16 commits intomasterfrom
next

Conversation

@10xjs
Copy link
Copy Markdown
Contributor

@10xjs 10xjs commented Dec 23, 2016

Add recent changes from next into master.

/cc @izaakschroeder

Neal Granger and others added 16 commits December 22, 2016 16:23
Allow custom `removePath` values to contain route params. This behavior matches the automatic `removePath` creation logic.
Remove the previousPath reducer and related conditional `router.goBack` logic. This never really worked correctly in practice since using the back function of history leaves the reducer with the wrong `previousPath` value (actually the "next" path). A proper solution would be to store an array of location history, and push or pop the location on navigation.

It's better to just keep things simple.
All of the `relocation` connector config can be assigned as props on the connected component instance or configured within the call to the `relocation` connector.

Instead of taking separate render map and config parameters, the connector now takes a single default props object. The render map can be defined within as `components` or can be provided as a `components` prop on the rendered instance.

In addition an optional `scope` option allows namespacing the consumed and generated props. This is designed to prevent conflicts with existing props on the connected component and allows composition with multiple `relocation` connector calls on the same component.
Refactor connector config and introduce scope.
Remove the `Children.only` check in the `RelocationRouter` render method. It is perfectly valid to have zero or more children here. This was only causing problems.
Prevent unwanted `relocation` specific props from getting passed down to the connected component.
Remove unwanted props from connected component.
Remove child restriction on RelocationRouter.
Allow param interpolation in removePath.
Remove the prop merging magic from the selectors. The original intention was to allow multiple instances of a component with a given id to exist, but to have them collapsed down and merged in the selector. This would have been useful for a component that was the product of props from a route component _and_ a dispatched component. However the complexity this added far outweighed the benefit, and the behavior was not intuitive.

The new version of `addComponent` no longer has the option for a custom id, and will not result in props merging with existing components.

A new `setComponent` action is used when the id must be explicitly specified. If an existing component with the given id exists, it is replaced rather than merged on to.

What does remain of the component merging logic is a new `updateComponent` action that can be used to update the props of an existing component. Props dispatched in the `updateComponent` _are_ merged into the existing props of the component with the matching id. An `update` function is also now included alongside the `remove` function on each component returned through the connector. This offers an interface for updating the "state" of the component where `update` is used like react `setState`.
Add missing propTypes.shape call.
Remove `RelocationRouter` component and related logic from state and connect component. Tightly binding this lib to React Router is not the best idea.

The behavior removed here can be easily replicated by manually dispatching `setComponent` from the `componentWillMount` and `removeComponent` from the `componentWillUnmount` method of a route handler component.
@10xjs 10xjs merged commit 4a8a76e into master Dec 23, 2016
@10xjs 10xjs deleted the next branch December 23, 2016 08:12
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

Successfully merging this pull request may close these issues.

1 participant