1.0.1 • Published 5 years ago

use-cofx v1.0.1

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

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