use-cofx
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

use-cofx Build Status

Use cofx with react hooks

import useCofx from 'use-cofx';

function* fetchMovies() {
  const resp = yield call(fetch, '/movies');
  const json = yield call([resp, 'json']);
  return json;
}

const App = () => {
  const { loading, error, value } = useCofx(fetchMovies);

  if (loading) {
    return <div>Loading ...</div>
  }

  if (error) {
    return <div>Error: {value}</div>
  }

  return <div>{value}</div>
};

See cofx for more information on what cofx can do

Readme

Keywords

none

Package Sidebar

Install

npm i use-cofx

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

7.97 kB

Total Files

15

Last publish

Collaborators

  • neurosnap