From af9da425e799863cc7f0ffe98d709a1945506b61 Mon Sep 17 00:00:00 2001 From: Tadao Iseki Date: Tue, 7 Jan 2020 22:28:24 +0900 Subject: [PATCH] Add API docs --- README.md | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 33c58a1..70e2719 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # use-lazyload-ref -[![npm version](https://badge.fury.io/js/use-lazyload-ref.svg)](https://badge.fury.io/js/use-lazyload-ref) ![CI Status](https://github.com/saitoeku3/use-lazyload-ref/workflows/Node%20CI/badge.svg) +[![GitHub license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/saitoeku3/use-lazyload-ref/blob/master/LICENSE) [![npm version](https://badge.fury.io/js/use-lazyload-ref.svg)](https://badge.fury.io/js/use-lazyload-ref) ![CI Status](https://github.com/saitoeku3/use-lazyload-ref/workflows/Node%20CI/badge.svg) -> Custom hook to use lazy load easily +> Custom hook to use lazyload easily -## Install +## Installation ``` $ npm install use-lazyload-ref @@ -13,22 +13,44 @@ $ yarn add use-lazyload-ref ## Usage +To enable lazy loading, simply specify `ref` and `data-src` attributes. + ```jsx import React from 'react' import useLazyloadRef from 'use-lazyload-ref' const Component = ({ url }) => { - const [ref, isLoaded] = useLazyloadRef() + const [ref, hasLoaded] = useLazyloadRef() return ( - <> +
{isLoaded || } - - + + {/*