Skip to content

Commit

Permalink
Merge pull request #301 from wootsbot/fix-docs-example
Browse files Browse the repository at this point in the history
fix: docs, add variable cookies
  • Loading branch information
maticzav authored Jun 22, 2020
2 parents 79be2bc + f1aa4b2 commit 299af61
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function Me({ cookies }) {

export async function getServerSideProps({ ctx }) {
// Parse
parseCookies(ctx)
const cookies = parseCookies(ctx)

// Set
setCookie(ctx, 'fromGetServerSideProps', 'value', {
Expand All @@ -60,22 +60,22 @@ export async function getServerSideProps({ ctx }) {
// Destroy
// destroyCookie(ctx, 'cookieName')

return { cookies };
};
return { cookies }
}
```

OR

```js
import nookies from 'nookies'

export default function Me () {
export default function Me() {
return <div>My profile</div>
}

export async function getServerSideProps({ ctx }) {
// Parse
nookies.get(ctx)
const cookies = nookies.get(ctx)

// Set
nookies.set(ctx, 'fromGetInitialProps', 'value', {
Expand All @@ -86,7 +86,7 @@ export async function getServerSideProps({ ctx }) {
// Destroy
// nookies.destroy(ctx, 'cookieName')

return { cookies };
return { cookies }
}
```

Expand All @@ -111,7 +111,7 @@ function handleClick() {
// destroyCookie(null, 'cookieName')
}

export default function Me () {
export default function Me() {
return <button onClick={handleClick}>Set Cookie</button>
}
```
Expand Down

0 comments on commit 299af61

Please sign in to comment.