mhui-rn
v1.18.6
Published
米家扩展程序中使用的 React Native 组件库
Readme
米家扩展程序中使用的 React Native UI 组件
组件文档
变更日志
按需加载
Metro bundler (RN 0.61) 不支持 tree-shaking,默认从 barrel 导入会将所有组件打包。推荐使用 babel-plugin-import 实现按需加载。
1. 安装依赖
npm install babel-plugin-import -D2. 配置 babel.config.js
const mhuiImportMap = require('mhui-rn/importMap');
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
['import', {
libraryName: 'mhui-rn',
camel2DashComponentName: false,
customName: (name) => mhuiImportMap[name],
}, 'mhui-rn'],
],
};3. 使用方式不变
// 写法不变,插件会自动转换为深路径引用
import { Switch, Slider } from 'mhui-rn';
// 实际编译为:
// import { Switch } from 'mhui-rn/dist/hyperOS/components/switch';
// import { Slider } from 'mhui-rn/dist/hyperOS/components/slider';注意,在非 miot-plugin-sdk 中使用,需要安装一下依赖
npm install [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]
