Home / Companies / Gatsby / Blog / Post Details
Content Deep Dive

How to Use Function Props with Gatsby’s Slice API

Blog post from Gatsby

Post Details
Company
Date Published
Author
Paul Scanlon
Word Count
1,011
Company Posts That Month
7
Language
English
Hacker News Points
-
Post removed?
No
Summary

Gatsby 5 introduced the Slice API to enhance the efficiency of updating common components across a website by allowing these components to be built separately and then integrated into existing pages. This approach, however, restricts the use of non-serializable props, such as functions, which cannot be reliably serialized for high-precision incremental builds due to their non-primitive nature. To work around this limitation, developers are encouraged to use React's Context API to provide and consume functions within slices rather than passing them as props. This method ensures a better developer experience by maintaining the integrity and precision of builds. Despite the restriction, the Slice API offers significant speed advantages during site-wide updates, making it a valuable tool for developers. Paul Scanlon shares insights and a practical example of implementing a theme toggle using this approach, emphasizing the benefits of adapting to the Slice API's design for optimal performance.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
Developer Experience 2 319 130 66 +33%
Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.