@knocklabs/react-feed

0.1.7 • Public • Published

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:

  1. git clone git@github.com:knocklabs/react-feed.git && cd react-feed
  2. npm i
  3. npm run dev

Example

There's an example application that you can load in your browser for local development under the example/ directory.

  1. cd example
  2. yarn
  3. yarn run start

It's set to point to localhost:4000, which is the dev instance of the Knock API.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.7
    9
    • latest

Version History

Package Sidebar

Install

npm i @knocklabs/react-feed

Weekly Downloads

72

Version

0.1.7

License

MIT

Unpacked Size

1.03 MB

Total Files

37

Last publish

Collaborators

  • cjbell