feathers-react-hooks
v1.1.1
Published
react hooks for use with feathersjs
Downloads
5
Maintainers
Readme
React hooks for use with feathersjs.
Install
npm install --save feathers-react-hooks
Hooks
useAuthentication
— tracks authentication status. callsapp.authenticate()
useSetting
— tracks an application setting.
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>
);
}