feathers-react-hooks

1.1.1 • Public • Published

current version Build Status Coverage Status Mutation testing badge semantic-release Commitizen friendly Greenkeeper badge

React hooks for use with feathersjs.

Install

npm install --save feathers-react-hooks

Hooks

useAuthentication

Tracks authentication status. Calls app.authenticate().

import { useAuthentication } from 'feathers-react-hooks';

export default function YourReactComponent() {
  const isAuthenticated = useAuthentication(app);

  if (isAuthenticated === null) {
    return 'authenticating...';
  }

  return isAuthenticated
    ? 'authenticated!'
    : 'not authenticated';
}

useSetting

Tracks an application setting.

import { useSetting } from 'feathers-react-hooks';

export default function YourReactComponent() {
  const [value, setValue] = useSetting(app, 'setting_name', 'default value');

  return (
    <button type="button" onClick={() => setValue('new value')}>
      {value}
    </button>
  );
}

Package Sidebar

Install

npm i feathers-react-hooks

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

16.3 kB

Total Files

13

Last publish

Collaborators

  • saiichihashimoto