lf7817 / anu

the React16-compat mini library

Home Page:https://rubylouvre.github.io/anu/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

anu

GitHub license npm version CircleCI PRs Welcome

npm install anujs

读作 安努 ,苏美尔的主神,开天辟地。一个高级兼容官方React16的迷你React框架,用于上线时无痛替换React,压缩整个项目的体积。 QQ交流学习群: 370262116

体积变化

数据来源: https://bundlephobia.com/

特点:

  1. 支持React16的各种新功能,Fragment, componentDidCatch, creactContext, createRef, forwardRef...
  2. 体积非常迷你(3000行相对于react+react-dom的3万行, gz为其1/3大小)
  3. 跑通官方700多个单元测试(其他迷你库都无法跑官方测试)
  4. 支持React全家桶(react-redux, react-router-dom, react-router-redux, react-lazy-load, react-hot-loader...)
  5. 支持99%的antd组件

官方脚手架

https://github.com/RubyLouvre/create-anu-app

IE8脚手架

https://gitee.com/menhal/React_IE8_boilerplate

image

开源协议

MIT

轻松切换已有的React项目

//webpack配置
resolve: {
   alias: {
      'react': 'anujs',
      'react-dom': 'anujs',
        // 若要兼容 IE 请使用以下配置
        // 'react': 'anujs/dist/ReactIE',
        // 'react-dom': 'anujs/dist/ReactIE',
        // 'redux': 'anujs/lib/ReduxIE',//这主要用于IE6-8,因为官方源码中的isPlainObject方法性能超差
        // 如果引用了 prop-types 或 create-react-class
        // 需要添加如下别名
        'prop-types': 'anujs/lib/ReactPropTypes',
        'create-react-class': 'anujs/lib/createClass'
        //如果你在移动端用到了onTouchTap事件
        'react-tap-event-plugin': 'anujs/lib/injectTapEventPlugin',  
   }
},

详细用法与示例见 wiki

测试

npm test

About

the React16-compat mini library

https://rubylouvre.github.io/anu/

License:Apache License 2.0


Languages

Language:JavaScript 97.7%Language:HTML 2.3%