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-j-page

v2.0.0-bate8

Published

json 2 page

Readme

react-jpage

JSON 2 Page

API

| 参数名 | 说明 | 必填 | 类型 | 默认值 | 备注 | | ------ | ---- | ---- | ---- | ------ | ---- | | PageContext | 全局上下文信息,在每个组件里面可以通过this.props.PageContext进行获取,只读,不可写 | 否 | Object | 无 | | | components | 所有被渲染的组件 | 是 | [key: string]: React.ReactType | 无 | | | schema | 描述组件结构的schema | 是 | OBS_Schema<Components, AllComponents> | 无 | https://www.yuque.com/jinci/mb5rax/wwnpig |

功能说明

布局

内置了布局组件Layout,内部把描述转换成css grid进行布局实现,组件文档

举个例子

使用Layout组件进行以下布局描述:

布局


<ReactJpage
  components={{header,content,sidebar,footer}}
  schema={{
    data: {
      Layout$1: {
        fields: {
          // 容器宽高
          style: {
            width: "430px",
            height: "300px"
          },
          // 每列列宽
          columns: ["1fr","100px"],
          // 每行行高
          rows: ["150px","1fr","100px"],
          // 边距大小
          gap: "1px",
          // 布局描述
          template: [
            // 三行两列
            ["header",  "header"],
            ["content", "sidebar"],
            ["footer",  "footer"]
          ]
        }
      }
    },
    hierarchy: {
      componentDetail: {},
      // 根组件
      root: "Layout$1",
      structure: {
        // 子元素组件
        Layout$1: ["header","content","sidebar","footer"],
      }
    }
  }}></ReactJpage>

联动属性

默认支持了两种联动形式的描述:主动式联动描述被动式联动描述

主要讲讲 被动式联动描述 的使用方法。


// 组件A
function CompoenntA(props){
  return <div>{props.data.count}</div>
}

// 组件B
function CompoenntB(props){
  return <button onClick={()=>{
    // 通过Jpage注入的方法 changeContext 触发联动
    props.changeContext({
      count: Date.now()
    })
  }}> 点击联动 CompoenntA </button>
}


<ReactJpage
  components={{CompoenntA,CompoenntB,CompoenntC}}
  schema={
    {
      //组件数据
      data: {
        CompoenntA: {
          // 被联动的数据
          effectFields: {
            /* 
            * $Context 为联动的上下文对象,CompoenntB 将会被识别,收集为
            * CompoenntA 的依赖,当 CompoenntB 组件里调用 this.props.changeContext({count: 1}) 的时候,CompoenntA 的 this.props.data.count 将会变化
            */ 
            "data.count": "$Context.CompoenntB.count + 1"
          },
          // 静态数据
          fields: {
            data: {
              a: 1
            }
          }
        },
        CompoenntB: {
          fields: {
            count: 2
          }
        },
        Layout: {
          fields: {
            template:[["CompoenntA","CompoenntB"]]
          }
        }
      },
      // 组件结构
      hierarchy: {
        // (选填)所包括的所有组件名
        component: [],
        // (选填)同类组件的共同数据
        componentDetail: {},
        // 顶层组件名
        root: "Layout",
        // 所包括的子组件
        structure: {
          Layout: ["CompoenntA","CompoenntB"]
        }
      }
    }
  }
></ReactJpage>

效果:

表达式属性

<ReactJpage
  components={{CompoenntA}}
  PageContext={{
    fetchData: {
      count: 100,
      size: 2
    }
  }}
  schema={
    {
      //组件数据
      data: {
        CompoenntA: {
          // 被联动的数据
          scriptFields: {
            // $Context => PageContext
            "data.count": "$Context.fetchData.count * $Context.fetchData.size"
          },
          // 静态数据
          fields: {
            data: {
              a: 1
            }
          }
        }
      },
      // 组件结构
      hierarchy: {
        // (选填)所包括的所有组件名
        component: [],
        // (选填)同类组件的共同数据
        componentDetail: {},
        // 顶层组件名
        root: "CompoenntA",
        // 所包括的子组件
        structure: {
          CompoenntA: []
        }
      }
    }
  }
></ReactJpage>