1.1.1 • Published 2 years ago

@hookers/use-data-loader v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

@hookers/use-data-loader

requires react 16.8+

Wait for a dom element to appear then execute a callback

install

yarn add @hookers/use-data-loader
import { useDataLoader } from '@hookers/use-data-loader';

export const Example: React.FC = () => {
    const dataLoader = async (searchTerm: string) => {
        const data = await ExternalApiCall(searchTerm);
        return proccessData(data);
    } 

    const [read, { error, currentData, isLoading }] = useDataLoader(dataLoader);
    
    return (
        <>
            <input type="text" placeholder="search..." onBlur={evt => read(evt.target.value)} />
            { isLoading ? <div>Loading</div> : null }
            { error ? <div>Error</div> : null }
            { data ? <div>{ data }</div> : null }
        </>
    );
}
1.1.1

2 years ago

1.1.0

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago