Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# useCookie Changelog

All notable changes to this project will be documented here. This project
adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.1.0](https://github.com/tylerwolff/useCookie/compare/7273486214108568046772a6f7c3dc855609d2bd...24ec23bb2f92d3fe3b124cddba49213232583a84) (2020-06-17)

### Features

- Expose the `getCookie` and `setCookie` function
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ A React hook for managing cookies with no dependencies.

## Installation

```
```bash
npm install react-use-cookie
```

or

```
```bash
yarn add react-use-cookie
```

Expand All @@ -35,22 +35,16 @@ export default props => {
};
```

You can also specify an optional third argument - an options object with the following keys:

```tsx
{
// The number of days the cookie is stored (defaults to 7)
days: number;
// The path of the cookie (defaults to '/')
path: string;
}
```
`setUserToken` accepts a second argument: `options`. Different to the named
export, for this one it is the second not the third argument. Take a look at
[setCookie](#setcookie) for more details.

This package also has a few other exports that can be used directly.

### `getCookie`

If you need to access a cookie outside of a React component, you can use the named `getCookie` export:
If you need to access a cookie outside of a React component, you can use the
named `getCookie` export:

```jsx
import { getCookie } from 'react-use-cookie';
Expand All @@ -63,7 +57,8 @@ const getUser = () => {

### `setCookie`

If you need to set a cookie outside of a React component, you can use the named `setCookie` export:
If you need to set a cookie outside of a React component, you can use the
named `setCookie` export:

```jsx
import { setCookie } from 'react-use-cookie';
Expand All @@ -72,7 +67,8 @@ const saveLocale = locale => {
};
```

You can also specify an optional third argument - the same options object as above:
You can also specify an optional third argument - the same options object as
above:

```tsx
{
Expand Down