npm.io
0.0.4 • Published 8 years ago

yreact

Licence
ISC
Version
0.0.4
Deps
0
Vulns
0
Weekly
0

yReact

a simple react

git clone https://github.com/yt1520406335/yReact.git

cd example/helloWorld/

npm run start

open your browser

use npm

npm install yreact --save
babel config
"plugins": [
    ["transform-react-jsx", {
        "pragma":  "y"
    }],
]
use in project (l suggest you should not use... a ha)
import { render, Component } from 'yreact'
const containerNode = document.getElementById('app')

class SubApp extends Component {
    constructor(props) {
        super(props)
        this.state = {
        }
    }

    render() {
        const {name} = this.props
        return (
            <div>
                {name}
            </div>
        )
    }
}

class TopApp extends Component {

    constructor(props) {
        super(props)
        this.state = {
            name: 'hello world',
        }
    }

    render() {
        const { children } = this.props
        const { name } = this.state
        return (
            <div>
                <input 
                    onChange={e => {
                        this.setState({
                            name: e.target.value
                        })
                    }}
                    value={name}
                    style={{ border: '1px solid black' }}
                />
                <div>
                    {name}
                </div>
                <SubApp name={`name: ${name}`}/>
                <SubApp name={`name: ${name}`}/>
            </div>
        )
    }
}

render(<TopApp />, containerNode)
learn from
issue

new a issue

update log

0.0.1

set up the environment to develop the project
just support mount into dom

  • not support lifecycle
  • not support event
  • not support Function component
  • other
0.0.2
  • support setState
  • There are still a lot of problems.
0.0.3
  • modify README.md