Skip to content

sweetpalma/gooact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gooact

Copyright 2018 SweetPalma <sweet.palma@yandex.ru>

Own React in 160 lines of JavaScript - repository for Medium article code: https://medium.com/@sweetpalma/gooact-react-in-160-lines-of-javascript-44e0742ad60f

Introduction

React is a great library — many developers instantly fell in love with it due to simplicity, performance and declarative way of doing things. But personally I have a specific reason what makes it so special for me — and that’s how it works under the hood. I find ideas that stand behind React simple yet strangely fascinating — and I believe that understanding its core principles would help you writing faster and safer code.

So I write a Medium article where how to write a fully functional React clone, including Component API and own Virtual DOM implementation. This is a public repository of Gooact itself.

Installation & Usage

This is a standalone version of Gooact - it can be installed with NPM:

npm install sweetpalma/gooact

And used just as a regular JavaScript library:

import Gooact, {render, Component} from 'gooact';

Due to its nature, Gooact can consume JSX - just don't forget to hook up the Babel together with React preset:

/** @jsx Gooact.createElement */
render(<div>Hello World!</div>, document.getElementById('root'));

Notice that @jsx pragma comment - without it Babel will fail to tie proper element factory function. Check example folder for a bigger snippet.

License

Gooact is licensed under the MIT License, what allows you to use it for basically anything absolutely for free. It would be great if somebody will find it useful.