Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ht-react

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ht-react

normal utils by qianzhixiang

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

响应式 REACT 工具

q-reactive-react 主要赋予了 react 能响应式更新的功能。

响应式更新包括两个部分:

  1. 数据发生了改变,组件能够自动更新,而不需要手动 setState
  2. 数据发生了改变,组件不需要全部更新,只更新和数据相关的组件。

如此一来:

  1. 开发可以更加专注于逻辑层。
  2. 即使一个组件很大,你也不用担心重新渲染带来的额外消耗,所有的组件都能够知道自己什么时候能更新。性能更好。

事实上,它比你想象的更强大, 它可以定位到最细粒度的组件更新,

一个例子

这里我会通过一个例子来介绍响应式工具的使用:

import React, { Component } from 'react';
import { H, HComponent, Model, Ref, State, Prop, Watch } from 'q-reactive-react';

@HComponent()
export class Test extends Component {
  @State() count = 1;

  @State() input = 'ss';

  @Prop() name;

  @Watch('count')
  onCountChange(newValue: number, oldValue: number) {
    //...
  }

  ref = React.createRef<any>();

  inputRef = React.createRef<any>();

  componentDidMount() {
    console.log(this.ref, this.inputRef);
  }

  render() {
    return (
      <div>
        <div
          {...Ref(() => this.ref)}
          onClick={() => {
            this.count++;
          }}
        >
          {H(() => this.count)}
          {this.name}
        </div>
        <div>
          {H(() => this.input)}
          <input {...Ref(() => this.inputRef)} {...Model(() => this.input)} />
        </div>
      </div>
    );
  }
}

Keywords

FAQs

Package last updated on 02 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc