Skip to content

Commit

Permalink
fix(docs): add example for pageContext usage within a page (#11580)
Browse files Browse the repository at this point in the history
## Description

This page explains very well that you can pass `context` to a page automatically created, but it's missing an example of how to use it in a page via `pageContext`. I think it is important to explicitly explain it because the name of the variable is different to the prop name.
I added an example.

## Related Issues
I didn't find any related issues.
  • Loading branch information
guayom authored and DSchau committed Feb 5, 2019
1 parent a0bc79b commit c2ffc07
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/docs/creating-and-modifying-pages.md
Expand Up @@ -152,3 +152,15 @@ exports.onCreatePage = ({ page, actions }) => {
})
}
```

On your pages and templates, you can access your context via the prop `pageContext` like this:

```jsx
import React from "react"

const Page = ({ pageContext }) => {
return <div>{pageContext.house}</div>
}

export default Page
```

0 comments on commit c2ffc07

Please sign in to comment.