npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dany-react-hook-frame

v1.0.0

Published

dany-react-hook-frame React component

Readme

dany-react-hook-frame

Private react hook frame

##useAsyncTask 方法传入一个异步执行函数,以及该函数的依赖变量(可为空) 返回一个任务执行状态, 一个错误状态error, 执行状态loading, 执行结果data, 一个可外部修改返回结果的setData, 以及一个重执行函数的触发钩子。

import React, { Component, useState} from 'react'
import {render} from 'react-dom'
import { Button, Spin, Result, Input } from 'antd';
import 'antd/dist/antd.css';
import './index.css'
import { useAsyncTask } from '../../src'

const Demo = () => {
  const [id, setId] = useState(1);
  const [editValue, setEditValue] = useState('修改返回值');
  function addID() {
    setId(id + 1);
  }

  function reduceId() {
    setId(id - 1);
  }
 
  async function testFunction() {
    const result = await fetch(`https://jsonplaceholder.typicode.com/posts/${id}`);
    if (result.status !== 200) {
      throw new Error('bad status = ' + result.status);
    }
    return result.json();
  }
  const moduleStateTest = useAsyncTask(testFunction, [id]);

  function inputChange (e) {
    setEditValue(e.target.value);
  }

  function editData() {
    let preData = { ...moduleStateTest.data };
    preData.body = editValue;
    moduleStateTest.setData(preData);
  }
  console.log(moduleStateTest);
  const ResultPanel = () => {
    let panelJsx = null
    moduleStateTest.error ? panelJsx = <Result
      status="error"
      title="请求失败" />
    :
    panelJsx = <Result
      status="success"
      title="请求成功"
      subTitle={moduleStateTest.data ? moduleStateTest.data.body : ''}
    />
    return panelJsx;
  }
  return <div className="test-block">
    <Spin spinning={moduleStateTest.loading}>
      {ResultPanel()}
      <p>ID:{id}</p>
      <Input placeholder="输入修改值" onChange={(e) => { inputChange(e) }} style={{ width: '300px'}}/>
      <Button type="primary" onClick={() => addID()}>add id</Button>
      <Button type="danger" onClick={() => reduceId()}>reduce id</Button>
      <Button onClick={() => editData()}>edit data</Button>
    </Spin>
  </div>
}

render(<Demo/>, document.querySelector('#demo'));