Current Data

Refreshing

You've seen how the Navigation router helps you pass data between different States in your application. But, you often want to pass data without changing State. You can build Hyperlinks that change data without changing State using the RefreshLink component. It's similar to the NavigationLink component except there's no stateKey prop, because the destination State always matches the current one.

In the email example, when the user opens an email we can add a Hyperlink that expands the mail so they can view the full conversation. When they click the Hyperlink, we change the expand data item to true and stay on the 'mail' State. Because we’re not changing State, we use the RefreshLink component to build the Hyperlink.

<NavigationReact.RefreshLink 
  navigationData={{id: 12, expand: true}}>
  Expand Thread
</NavigationReact.RefreshLink>

Alternatively, you can programmatically pass the new data into the refresh function on the stateNavigator.

<NavigationReact.NavigationContext.Consumer>
  {({ stateNavigator }) => (
    <div onClick={() => stateNavigator.refresh({id: 12, expand: false})}>
      Expand Thread
    </div>
  )}
</NavigationReact.NavigationContext.Consumer>

Remembering Data

When you navigate to the same State, you often want to keep most of the current data unchanged. Instead of manually passing all these current data values into the navigationData prop, you can get the RefreshLink component to remember them for you. When you set includeCurrentData to true, the RefreshLink adds the current data to your navigation data and builds the Hyperlink out of the combined data. In the email example, the Hyperlink that expands the email must remember the current email id. We set includeCurrentData to true so we only have to pass the new expand value into the navigation data.

<NavigationReact.RefreshLink 
  navigationData={{expand: true}}
  includeCurrentData={true}>
  Expand Thread
</NavigationReact.RefreshLink>