Skip to content

JJVvV/melon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Melon

这个项目的目的是通过自己实现一个virtual-dom,有助于更好的理解React这类库的底层原理。

详细讲解

Installation

npm install

npm start

open localhost:3003

Example

//定义一个组件
let MyButton = {
	render: ({props, children}) => 
		<button onClick={addCount} {...props}>{children}{count}</button>
}
let count = 0
let addCount = () => {
	count++
	app()
}
//渲染函数,用来生成dom
let render = createApp(document.body)

let app = () => {
	render(<MyButton className="button">hello, button</MyButton>)
}

app()

Thanks

参考文献:

License

MIT

About

mini virtual dom,实现自己的React

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published