Skip to content

Commit

Permalink
Merge pull request #35 from spjpgrd/patch-1
Browse files Browse the repository at this point in the history
💡 Update readme for clarity and phrasing
  • Loading branch information
hinok authored Mar 5, 2020
2 parents 6e63d81 + b15fad3 commit da7cbc0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
- Handle redirects.
- Support ![TypeScript](https://user-images.githubusercontent.com/1313605/53197634-df9a6d00-361a-11e9-81ba-69f8a941f8a2.png)
- Useful for handling internal routing.
- Easily prevent leaving your app by users.
- Easily keep your users inside your app.

## Demo

[![Edit react-router-last-location](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/zn208l91zp)

## Note: Last location != Previous browser history state

This library only returns the location that has been active before the recent location change in the current window lifetime.
This library only returns the location that was active right before the recent location change, during the lifetime of the current window.

This means, it is not equal to the "location that happened before navigating to this history state", or in other words "location to which you'll be redirected upon clicking browser back button".
This means, it is not equal to the "location you were at before navigating to this history state".

In other words, the location this library provides is not necessarily the same as the one when you click the browser's back button.

**Example 1**

Expand Down Expand Up @@ -146,7 +148,7 @@ const Logger = ({ lastLocation }) => (
export default withLastLocation(Logger);
```

### Use `RedirectWithoutLastLocation` to don't store redirects as last location
### Use `RedirectWithoutLastLocation` to not store redirects as last location

```jsx
import React from 'react';
Expand All @@ -159,7 +161,9 @@ const MyPage = () => (
export default MyPage;
```

You can still use regular `<Redirect />` component from `react-router` but then you need to pass manually the `state: { preventLastLocation: true }`, like below:
You can still use a regular `<Redirect />` component from `react-router`.

If you do, you'll then you need to manually pass the `state: { preventLastLocation: true }`, like below:

```jsx
import React from 'react';
Expand Down

0 comments on commit da7cbc0

Please sign in to comment.