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

greatjoy-hooks

v1.0.3

Published

A React input component based on antd-mobile with enhanced features

Downloads

27

Readme

GreatJoy Hooks

一套封装了常用功能的 React Hooks 库,提供了 URL 参数获取、样式动态注入和组件属性增强等功能。该库专注于解决 React 开发中的常见问题,帮助开发者提高开发效率。

特性

  • 🪝 实用 Hooks: 提供常用的自定义 Hooks,简化复杂逻辑
  • 🔧 轻量级: 专注于核心功能,不添加不必要的依赖
  • 📦 易于使用: 简单直观的 API 设计,开箱即用
  • 🛡️ TypeScript 支持: 完整的 TypeScript 类型定义,提供更好的开发体验
  • 🔄 按需导入: 支持 tree-shaking,只打包你使用的功能

安装

使用 npm 安装:

npm install greatjoy-hooks

或者使用 yarn:

yarn add greatjoy-hooks

使用方法

基础使用

import { getParameterByName, useInjectStyles, attachPropsToComponent } from 'greatjoy-hooks';

getParameterByName - 获取 URL 参数

从 URL 查询参数或 hash 中获取指定参数值。

// 获取 URL 查询参数
const userId = getParameterByName('userId');

// 获取 URL hash 参数
const token = getParameterByName('token', true);

useInjectStyles - 动态样式注入

将样式动态注入到文档中,避免重复注入,特别适用于组件库开发。

import styles from './Component.module.css';
import { useInjectStyles } from 'greatjoy-hooks';

function MyComponent() {
  useInjectStyles(styles, 'MyComponent');
  
  return <div className="my-component">Hello World</div>;
}

attachPropsToComponent - 组件属性增强

给 React 组件附加额外属性(如静态方法、子组件、常量等)。

import MyComponent from './MyComponent';
import SubComponent from './SubComponent';

const EnhancedComponent = attachPropsToComponent(MyComponent, {
  Sub: SubComponent,
});

// 使用方式
// <EnhancedComponent />
// <EnhancedComponent.Sub />

样式引入方式

自动引入(推荐)

使用 useInjectStyles Hook 自动注入样式,无需手动引入 CSS 文件:

import styles from './Component.module.css';
import { useInjectStyles } from 'greatjoy-hooks';

function MyComponent() {
  useInjectStyles(styles, 'MyComponent');
  // 组件逻辑...
}

手动引入

如果需要手动引入样式文件:

// 在你的应用入口文件中引入样式
import 'greatjoy-hooks/dist/index.min.css';

构建和打包

本库使用 Vite 进行构建和打包,代码经过混淆处理,外部使用者只能看到类型定义而无法查看具体实现代码。构建配置已经优化,确保打包后的代码具有良好的压缩率和安全性。

License

MIT