1.1.1 • Published 5 years ago

feathers-react-hooks v1.1.1

Weekly downloads
16
License
MIT
Repository
github
Last release
5 years ago

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>
  );
}