we're trying to pass additional data to the slices via the SliceZone with the sliceProps attribute. However, I"m not seeing any of the data passed in my slices.
However, in my slice, I don't see the additional data getting passed in, just the slice data. Does it get passed in a specific attribute like data or sliceProps or ?
Hey there, can you please update to next-slicezone@0.1.2 and try again.
Before 0.1.0, adding the sliceProps property wasn’t a possibility, so this is probably why it's not working.
Yes, those props will become available in all the Slices. You can pass a random object to the sliceProps instead of the props of the function. And see if that works.
Could you show me the code snippet where you're passing the props and how you're retrieving them in the Slice component?
Pau
closed , flag & select 'Something Else' to reopen.
9
This thread has been closed due to inactivity. Flag to reopen.
There might be a better way to do this (please let me know if there is ) but I need to pass several functions and variables to the slices, predominately for event listeners that will affect other areas on the website which are not slices.
So far, the only way I seem to be able to pass these properties to the slices is by using the 'context' parameter. Would it not also make sense to add this the 'sliceProps' to all other language packages (incl. gatsby).
I don't know of any alternative to this right now, can you provide me with your exact use case so that I can maybe assist you?
I've created a feature request for this on the @prismicio/react package and made the team aware of your request. You will be able to track the request there.
It would be great to have a sliceProps param in @prismicio/react package's SliceZone.
My use case is that I want to have a slice that displays the three latest articles.
I could fetch them dynamically in the slice component but I'd like to have it at build time, so fetched in getStaticProps.
In the meantime, I will use context props and pass my 3 articles to all the slices of my page.