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-glue-redux

v1.4.0

Published

relate react to glue-redux,like react-redux

Readme

react-glue-redux

glue-redux的连接库

基于glue-redux的react连接库

安装

npm i react-glue-redux -P
# 包原名为react-glux,1.3.1版本后react-glux改名为react-glue-redux

查看示例

git clone https://github.com/ZhouYK/react-glux.git
npm install
npm start

然后访问 http://localhost:8888

Api

  • destruct

destruct(store)(model) | 代码

入参

  • store(必传)

    redux的生成的store对象

  • model(必传)

    自定义的数据对象,必须是plain object

返回

  • { reducers, connect }

    包含reducers和connect属性的对象

    • reducers

      redux中的reducer函数的对象集合,可直接用于combineReducers

    • connect 代码

      HOC---链接store与组件,帮助组件实时获取数据,向组件注入数据

如何使用

  // store.js
  import {
    createStore, combineReducers,
  } from 'redux';
  import app from './model';
  import { destruct } from 'react-glue-redux';
  
  const store = createStore(() => {});
  const { reducers, connect } = destruct(store)({ app });
  store.replaceReducer(combineReducers(reducers));
  
  export {
    store,
    connect, // 导出连接React组件的HOC
  };

connect(model)(Component)

  • model

必须是对象,从state拿到的数据将以该对象的展开结构注入组件

  • Component

react组件

如何使用

  • 先定义数据模型
 // model.js
 import { gluer } from 'glue-redux';
 
 const users = gluer((data, state) => [data, ...state], []);
 
 const app = {
   users,
 };
 export default app;
  • 在组件中注入数据
  // UserList.jsx
  import React, { Component } from 'react';
  import pt from 'prop-types';
  import { connect } from './store';
  import model from './model';
  
  class UserList extends Component {
    static propTypes = {
      users: pt.array.isRequired,
    }
  
    renderUsers = () => {
     ...
    }
  
    render() {
      return (
        <section>
          { this.renderUsers() }
        </section>
      );
    }
  }
  
  export default connect(model)(UserList);// model的结构为{ users },注入组件的属性则为this.props.users

Author

ZhouYK

License

MIT licensed