Comparing version 1.8.3 to 1.8.4
## Confirming Navigation | ||
Sometimes you may want to prevent the user from going to a different page. For example, if they are halfway finished filling out a long form, and they click the back button, you may want to prompt them to confirm they actually want to leave the page before they lose the information they've already entered. For these cases, `history` lets you register [transition hooks](Glossary.md#transitionhook) that return a prompt message you can show the user before the [location](Glossary.md#location) changes. For example, you could do something like this: | ||
Sometimes you may want to prevent the user from going to a different page. For example, if they are halfway finished filling out a long form, and they click the back button, you may want to prompt them to confirm they actually want to leave the page before they lose the information they've already entered. For these cases, `history` lets you register [transition hooks](Terms.md#transitionhook) that return a prompt message you can show the user before the [location](Terms.md#location) changes. For example, you could do something like this: | ||
@@ -12,3 +12,3 @@ ```js | ||
You can also simply `return false` to prevent a [transition](Glossary.md#transition). | ||
You can also simply `return false` to prevent a [transition](Terms.md#transition). | ||
@@ -15,0 +15,0 @@ If your transition hook needs to execute asynchronously, you can provide a second `callback` argument to your transition hook function that you must call when you're done with async work. |
## Getting Started | ||
The first thing you'll need to do is create a [history object](Glossary.md#history). The main `history` module exports several different [`create*` methods](Glossary.md#createhistory) that you can use depending on your environment. | ||
The first thing you'll need to do is create a [history object](Terms.md#history). The main `history` module exports several different [`create*` methods](Terms.md#createhistory) that you can use depending on your environment. | ||
@@ -37,3 +37,3 @@ - `createHistory` is for use in modern web browsers that support the [HTML5 history API](http://diveintohtml5.info/history.html) (see [cross-browser compatibility](http://caniuse.com/#feat=history)) | ||
The [`path`](Glossary.md#path) argument to `pushState` and `replaceState` represents a complete URL path, including the [query string](Glossary.md#querystring). The [`state`](Glossary.md#locationstate) argument should be a JSON-serializable object. In `setState`, the properties in `state` are shallowly merged into the current state. | ||
The [`path`](Terms.md#path) argument to `pushState` and `replaceState` represents a complete URL path, including the [query string](Terms.md#querystring). The [`state`](Terms.md#locationstate) argument should be a JSON-serializable object. In `setState`, the properties in `state` are shallowly merged into the current state. | ||
@@ -40,0 +40,0 @@ ```js |
## Location | ||
A [`location` object](Glossary.md#location) is conceptually similar to [`document.location` in web browsers](https://developer.mozilla.org/en-US/docs/Web/API/Document/location), with a few extra goodies. `location` objects have the following properties: | ||
A [`location` object](Terms.md#location) is conceptually similar to [`document.location` in web browsers](https://developer.mozilla.org/en-US/docs/Web/API/Document/location), with a few extra goodies. `location` objects have the following properties: | ||
@@ -5,0 +5,0 @@ ``` |
## Query Support | ||
Support for parsing and serializing [URL queries](Glossary.md#query) is provided by the `useQueries` [enhancer](Glossary.md#createhistoryenhancer) function. Simply use a wrapped version of your `createHistory` function to create your `history` object and you'll have a parsed `location.query` object inside `listen`. | ||
Support for parsing and serializing [URL queries](Terms.md#query) is provided by the `useQueries` [enhancer](Terms.md#createhistoryenhancer) function. Simply use a wrapped version of your `createHistory` function to create your `history` object and you'll have a parsed `location.query` object inside `listen`. | ||
@@ -5,0 +5,0 @@ ```js |
@@ -8,2 +8,2 @@ ## Table of Contents | ||
- [Caveats of Using Hash History](HashHistoryCaveats.md) | ||
- [Glossary](Glossary.md) | ||
- [Glossary](Terms.md) |
{ | ||
"name": "history", | ||
"version": "1.8.3", | ||
"version": "1.8.4", | ||
"description": "A minimal, functional history implementation for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
0
134170
29
2470