use-lazy-data
v1.1.1
Published
Load when used and only once - (使用时加载且只加载一次)
Downloads
6
Readme
use-lazy-data
- Load when used and only once - (使用时加载且只加载一次)
Install
pnpm add use-lazy-data
yarn add use-lazy-data
npm install use-lazy-data
Usage
import useLazyData from 'use-lazy-data'
const data = useLazyData(() => ({
name: 'Jaye'
}))
console.log(data) -> "{}"
data.value
console.log(data) -> "{ value: { name: 'Jaye' } }"
const data2 = useLazyData({
name: () => 'Jaye',
})
console.log(data2) -> "{}"
data2.name
console.log(data2) -> "{ name: 'Jaye' }"