johno / digital-garden

🌻[WIP] Gatsby Theme to build your own digital garden 🌻🥀🌸
216 stars 11 forks source link

rename "use..." functions to "get..." #134

Closed riencoertjens closed 5 years ago

riencoertjens commented 5 years ago

I was trying to build the examples and got: error React Hook "useSiteMetadata" is called in function "seoTitle" which is neither a React function component or a custom React Hook function error React Hook "useSiteMetadata" is called in function "metaDescription" which is neither a React function component or a custom React Hook function

capitalising solved this

adrw commented 5 years ago

Thanks for tackling this error and suggesting a solution!

I think the error may be more related to the prefix of the function being use which might now be special according to React Hook: A custom Hook is a JavaScript function whose name starts with ”use” and that may call other Hooks. https://reactjs.org/docs/hooks-custom.html

I think a better solution is to rename the function to getSiteMetadata (or something else without the use prefix) since the proposed one seems to be getting around the React errors by capitalizing and masquerading the function as a component.

Could you try a simple rename of both useSiteMetadata and useOptions across the codebase to getSiteMetadata and getOptions respectively and see if that works?

riencoertjens commented 5 years ago

allright, done those changes, it had been a long day