Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add rax-componentwrapper #399

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

cryzzchen
Copy link
Contributor

@cryzzchen cryzzchen commented Sep 13, 2021

支持

阿里小程序(运行时) / 微信小程序(运行时)

描述

在运行时小程序中,默认所有的数据更新都使用 PagesetData 方法。对于部分需要频繁更新数据的元素来说,可以在元素外包裹 rax-componentwrapper 的方式,自动将该元素转成自定义组件,当元素数据发生变化时,使用组件的 setData,来起到性能优化的目的。

需要注意:在阿里小程序中,需要开启基础库 2.0 构建或开启 component2 功能时,才能正常使用该组件,否则将降级使用 PagesetData 方法。

安装

$ npm install rax-componentwrapper --save

使用

import ComponentWrapper from 'rax-componentwrapper';

例子

import { createElement, render, useState } from 'rax';
import DriverUniversal from 'driver-universal';
import ComponentWrapper from 'rax-componentwrapper';
import View from 'rax-view'

const App = () => {
  const [count, setCount] = useState(1);

  return (
    <View>
      <View onClick={() => setCount(count + 1)}>plus</View>
      <ComponentWrapper>
        <View>{count}</View>
      </ComponentWrapper>
    </View>
  );
}


render(<App />, document.body, { driver: DriverUniversal });

@cryzzchen cryzzchen changed the title Feature/component wrapper feat: add rax-componentwrapper Sep 24, 2021
{
"name": "rax-componentwrapper",
"version": "1.0.0",
"description": "组件功能描述",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修改一下 description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants