Skip to content

"branch" (or "routes") in beta4 #1788

@taion

Description

@taion

It looks like the array of currently active routes is no longer passed down to route components. This makes things a bit tricky for the Relay integration, because I was previously using branch (now routes on RoutingContext) for two reasons:

  1. Our API is just to replace createElement and to add extra prop(erties) to routes. However, to build the aggregated query, we need to pull together all the child queries at top level before any of the children render. I don't properly have access to any state I can use for this in createElement. Previously, I'd just been reading branch at top-level and doing everything there: https://github.com/relay-tools/react-router-relay/blob/v0.4.2/src/RouteAggregator.js#L28-L58
  2. For each child component, I consider the relevant set of route parameters to be the ones for that route and all parents. I use these to construct the relevant queries for each of those routes (since they may well need access to params from parent routes, but should not have access to params from their children): https://github.com/relay-tools/react-router-relay/blob/v0.4.2/src/getParamsForRoute.js#L7-L12

Strictly speaking, I can hack my way around this: https://github.com/relay-tools/react-router-relay/pull/28/files. However, would it be possible to expose branch to components again? (1) is a bit specific to Relay-style data fetching, but (2) might be useful more broadly.

I don't think I can the listen hook on history or set onUpdate on Router, because I need to observe the new branch synchronously with re-rendering the router.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions