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 🙏

© 2024 – Pkg Stats / Ryan Hefner

rnplus

v0.30.47

Published

React Native Plus

Downloads

74

Readme

RNPlus

npm npm

RNPlus 是 React Native 的前端拓展框架,简化并增强前端开发。

配合使用 rnxDemo,阅读该文档,风味更佳哦~

介绍

  • Base: 核心、插件机制、Utils
  • Router: 路由部分,包括同 Context 内的路由,以及和 Native View 之间的跳转
  • Redux:数据部分,与 Router 结合的单向数据流操作
  • Webx: 前端扩展部分,包括对 Style 的扩展和对事件的一些改动

开始

// 引入 RNPlus
import {
    PView,
    PComponent,
} from 'rnplus';

// 定义一个页面
class PageA extends PView {
    // ...
};
// 定义一个组件
class MyComp extends PComponent {
    // ...
};

核心API

业务开发者 API

PView 和 PComponent

开发者可以通过 class Demo extends PView {}class Demo extends PComponent {} 的方式创建 RNPlus View 或 Component,并使用 RNPlus 的插件。

例:

class Demo extends PView {
    render() {
        return <Text>Hello, RNPlus!</Text>
    }
}

注意:

不要修改对 PViewPComponent 的引用。以下写法是无效的

// 无效的写法
const MyView = PView;

class Demo extends MyView {
    render() {
        return <Text>Hello, RNPlus!</Text>
    }
}

之所以这样是因为 RNPlus 为方便开发,会通过配套的 babel 插件自动完成注册。如果你一定要像上面那样,你也可以通过以下方式手动完成注册:

const MyView = PView;

class Demo extends MyView {
    render() {
        return <Text>Hello, RNPlus!</Text>
    }
}

// 手动注册
Demo = RNPlus.register(Demo, 'Demo');

RNPlus.defaults

全局配置,用户可以配置一些全局的设置。

默认配置:

RNPlus.defaults = {
  appName: '',
  globalPlugins: ['router', 'redux'],
};

插件文档

暂见各自 README.md

插件开发者 API

RNPlus.addPlugin(name, adapter, ininFn, registerFn);

添加插件

  • name{String} 插件名
  • adapter: {Function} 适配器
  • ininFn: {Function} RNPlus 初始化回调函数
  • registerFn: {Function} PView/PComponent 注册时回调函数

示例

RNPlus.addPlugin('xxx', (Comp, opts, React, isView) => {
    // Comp : React Comp 组件实例
    // opts : 插件配置
    // React : React 对象
    // isView : 是否是 View (有可能是 Component)
}, (React) => {
    // React : React 对象
}, (RNPlusComp, isView) {
    // RNPlusComp : RNPlus Comp 组件 Class (PView/PComponent)
    // isView : 是否是 View (有可能是 Component)
});