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

react-skeleton-component

v1.0.4

Published

骨架屏组件

Readme

react-skeleton-component

react-skeleton-component是基于TypescriptReact Hooks封装的一个骨架屏组件,可在react项目中开箱即用。在页面数据加载完成前,先给用户展示出页面的大致结构(占位图),在拿到接口数据渲染出实际页面内容之后替换掉,这样不会造成网页长时间白屏或者闪烁,优化用户体验。

安装

// npm
$> npm install react-skeleton-component
// yarn
$> yarn add react-skeleton-component

快速入门 在 codesandbox 试试吧

import Skeleton from "react-skeleton-component";
    
export default function App() {
  ...
  ...// 定义一些变量或者执行一些操作blabla....
  ...
  
  return (
    <>
      <button onClick={handleClick.bind(null)}>button</button>
      // 数据没有请求回来之前展示占位图,请求回来展示真实数据
      <ul>
        {state.loading ? (
          <Skeleton className="item" count={10} /> 
        ) : (
          data.map((item) => (
            <li className="item" key={item.cell}>
              {item.name.title}
            </li>
          ))
        )}
        {state.error && <div>error</div>}
      </ul>
    </>
  );
}

react-skeleton-component组件有默认类名,设置了占位图的默认样式和动画效果,如果自带的效果不能满足需求的话,react-skeleton-component还有其他的一些可配置参数来满足不同的需求,具体看👇参数;

可配置参数

  • count: 可以展示几个占位图,number类型,默认为1;
  • width:占位图的宽度,number类型,默认为父元素宽度;
  • height:占位图的高度,number类型,默认为父元素高度;
  • circle: 占位图是否为圆形,boolean类型,默认为false;
  • className:类名,string类型,默认自带了“react-loading-skeleton”类名;
  • style:样式,React.CSSProperties类型,默认为空;
  • duration:渐变动画持续时间,number类型,默认为2s;
  • colorStart: 渐变动画的开始颜色,string类型,默认为空;
  • colorEnd:渐变动画的结束颜色,string类型,默认为空;
  • rem2px:传入的宽高是否需要转换成px,boolean类型,默认为false;