Skip to content

Lemenxzy/Copy-React

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

This is a study react and copy it project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published