copy-react

1.0.6 • Public • Published

copy-react

学习 react 并且造一个简易 react 为 copyReact, 编译 .copy 文件

Study react and copy it

why

学习 react 的原理。

want to learn principle for react...

install

npm i copy-react --save

use

main.copy

import Copy, {CopyComponent} from 'copy-react'

class Demo extends CopyComponent {
    constructor(props) {
        super(props);
        this.state = {
            num: 1
        };
    }

    handle = () => {
        this.setState({
            num: this.state.num + 1
        })
    };

    render() {
        return (
            <div id='container'>
                <input type='text' value='foo' />
                <a href="javascript:void(0)" onClick={this.handle}>点我加一</a>
                <span>数字😁: {this.state.num}</span>
            </div>
        )
    }
}

export default Demo;

index.copy

import Copy, { CopyRender } from 'copy-react';
import Demo from './index.copy'

CopyRender(<Demo />, document.getElementById('root'));

note

Compile .copy

link: https://www.npmjs.com/package/babel-preset-copy

example

link: https://github.com/Lemenxzy/Copy-React

Readme

Keywords

none

Package Sidebar

Install

npm i copy-react

Weekly Downloads

1

Version

1.0.6

License

MIT

Unpacked Size

11.7 kB

Total Files

10

Last publish

Collaborators

  • gyweqq