Migrating from @knocklabs/react-notification-feed
This guide will walk you through the steps of replacing @knocklabs/react-notification-feed
with @knocklabs/react
.
Please report any issues you encounter while upgrading.
Installation
Install the new React package
Or if you're using Yarn:
Changes to Knock providers
@knocklabs/react
introduces updated providers:
KnockProvider
authenticates the current user and provides access to the Knock client. It now acceptsuserId
,apiKey
, anduserToken
props.KnockFeedProvider
connects to an in-app feed channel using thefeedId
prop and no longer acceptsuserId
,apiKey
, anduserToken
props.
@knocklabs/react-notification-feed
Before using This code sample demonstrates a typical implementation of the NotificationFeedPopover
and annotates
points of change in the component APIs.
@knocklabs/react
After using With the new React SDK, the KnockProvider
component now wraps the KnockFeedProvider
component and handles authenticating with Knock.
rootless
removed and NotificationFeedContainer
added
The KnockFeedProvider
no longer wraps its children with default styles. If you were setting the rootless
prop to true, this change has no effect. Otherwise, you should wrap your notification feed with the NotificationFeedContainer
component to ensure the feed is properly styled.
Before
After
Use Knock hooks
You can continue to use the useKnockFeed
hook to build headless feed experiences.
You can use the useKnockClient
hook to access the Knock client.