[ ] Chore (a non-breaking change which is related to package maintenance)
[ ] Bug fix (a non-breaking change which fixes an issue)
[x] New feature (a non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to change)
Description
This PR adds a resolver prop that matches that of next-slicezone. This change makes the migration path smoother for users upgrading existing projects.
It is marked as deprecated in favor of the components prop. @prismicio/react's <SliceZone> will ultimately replace next-slicezone.
In a future major version, the resolver prop will be removed.
For reference, this is the type signature of the resolver function:
/**
* Arguments for a `<SliceZone>` `resolver` function.
*/
type SliceZoneResolverArgs<TSlice extends SliceLike = SliceLike> = {
/**
* The Slice to resolve to a React component.
*/
slice: TSlice;
/**
* The name of the Slice.
*/
sliceName: TSlice["slice_type"];
/**
* The index of the Slice in the Slice Zone.
*/
i: number;
};
/**
* A function that determines the rendered React component for each Slice in the
* Slice Zone.
*
* @deprecated Use the `components` prop instead.
*
* @param args - Arguments for the resolver function.
*
* @returns The React component to render for a Slice.
*/
export type SliceZoneResolver<
TSlice extends SliceLike = SliceLike,
TContext = unknown,
> = (
args: SliceZoneResolverArgs<TSlice>,
) => SliceComponentType<TSlice, TContext>;
Checklist:
[x] My change requires an update to the official documentation.
[x] All TSDoc comments are up-to-date and new ones have been added where necessary.
Types of changes
Description
This PR adds a
resolver
prop that matches that ofnext-slicezone
. This change makes the migration path smoother for users upgrading existing projects.It is marked as deprecated in favor of the
components
prop.@prismicio/react
's<SliceZone>
will ultimately replacenext-slicezone
.In a future major version, the
resolver
prop will be removed.For reference, this is the type signature of the
resolver
function:Checklist:
🦊