Knock React Feed
Usage
import {
KnockProvider,
FeedProvider,
NotificationBadge,
useFeedToken,
} from "@knocklabs/react-feed";
function App() {
return (
<KnockProvider apiKey={process.env.KNOCK_API_KEY}>
<MyComponent />
</KnockProvider>
);
}
function MyComponent() {
const currentUser = useCurrentUser();
const feedToken = useFeedToken(process.env.KNOCK_FEED_ID, currentUser.id);
return (
<header>
<FeedProvider token={feedToken}>
<NotificationBadge>
{({ onClose }) => (
<ActivityFeed
onActivityClick={() => {
onClose();
}}
/>
)}
</NotificationBadge>
</FeedProvider>
</header>
);
}
Development
To start up the build process in order to work with the library locally, either
in the example repo, or by linking elsewhere:
git clone git@github.com:knocklabs/react-feed.git && cd react-feed
npm i
npm run dev
Example
There's an example application that you can load in your browser for local development under the example/
directory.
cd example
yarn
yarn run start
It's set to point to localhost:4000
, which is the dev instance of the Knock API.