0.0.3 • Published 6 years ago

use-abortable-stream-fetch v0.0.3

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

use-abortable-stream-fetch

React hook for fetching streams that can be aborted.

Installation

yarn add use-abortable-stream-fetch

Usage:

import React, { useEffect } from 'react';
import useAbortableStreamFetch from 'use-abortable-stream-fetch';

const Logs = () => {
  const url = '...';
  const { data, error, abort } = useAbortableStreamFetch(url);

  useEffect(() => {
    dispatch(actions.processData(data));
  }, [data]);

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

export default Logs;