项目作者: saiichihashimoto

项目描述 :
react hooks for use with feathersjs
高级语言: JavaScript
项目地址: git://github.com/saiichihashimoto/feathers-react-hooks.git
创建时间: 2019-08-12T01:20:32Z
项目社区:https://github.com/saiichihashimoto/feathers-react-hooks

开源协议:MIT License

下载


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

React hooks for use with feathersjs.

Install

  1. npm install --save feathers-react-hooks

Hooks

useAuthentication

Tracks authentication status. Calls app.authenticate().

  1. import { useAuthentication } from 'feathers-react-hooks';
  2. export default function YourReactComponent() {
  3. const isAuthenticated = useAuthentication(app);
  4. if (isAuthenticated === null) {
  5. return 'authenticating...';
  6. }
  7. return isAuthenticated
  8. ? 'authenticated!'
  9. : 'not authenticated';
  10. }

useSetting

Tracks an application setting.

  1. import { useSetting } from 'feathers-react-hooks';
  2. export default function YourReactComponent() {
  3. const [value, setValue] = useSetting(app, 'setting_name', 'default value');
  4. return (
  5. <button type="button" onClick={() => setValue('new value')}>
  6. {value}
  7. </button>
  8. );
  9. }