Lesson
Create a Custom Hook for Site Metadata in Gatsby
Gatsby's useStaticQuery hook is really useful for getting site metadata from our Gatsby config into our components. In fact, it's so useful that we end up using it all over the place and duplicating a lot of code! Luckily, since useStaticQuery is just a React...
- Duration
- 4 min
- Access
- Free
- Transcript
- Needs source
Gatsby's useStaticQuery hook is really useful for getting site metadata from our Gatsby config into our components. In fact, it's so useful that we end up using it all over the place and duplicating a lot of code! Luckily, since useStaticQuery is just a React hook, we can use it to compose our own custom useSiteMetadata hook.