aotoo
aotoo is a react library, for simpler development of react components, it is like a lightweight redux that but more better, you can use aotoo in
INSTALL
yarn install aotoo
yarn install aotoo-web-widgets
NOTE
Must install aotoo-web-widgets
Aotoo based on micro-kernel design, support node
, web
and react-native
, in the web/node side, must be used together with aotoo-web-widgets
and in react-native
must be used together with aotoo-rn-widgets
Global Variable -- Aotoo
import aotoo
will automatically generate the global variable Aotoo
API
- aotoo
like a lightweight redux - aotoo.item
Data-based react div components method - aotoo.list
Data-based single-level list(ul.li) components method - aotoo.tree
Data-based multi-level list(ul.li) components method - aotoo.wrap
Wrap jsx dom or react class as a new react class method - aotoo.transTree
Based on some rules, single-layer data will be into multi-level(tree) data, method - aotoo.CombineClass
It is abstract class, Inheritance of this class will be very easy to implement react components - aotoo.render Encapsulated from react.render and better
Other Api
aotoo.find
aotoo.findIndex
aotoo.cloneDeep
aotoo.filter
aotoo.merge
aotoo.uniqueid
aotoo.isPlainObject
USAGE
aotoo
import aotoo from 'aotoo' Component { thisstate = test: '1234' } { return <div ='container'> thisstatetest <button ="btn">试试看</button> </div> } const Actions = { // ostate为原始state,不变 // curState为当前state,变化 let curState = thiscurState ostatetest = optscontent return ostate } // aotoo will merge `Test` and `Action` and then return a instance, it has some methods, like `$content` etc..., they be generated from `Actions` children, const instance = instance{ } instance
aotoo.item
// 1const testitem = Aotoo // 2const testitem = Aotoo Aotoo // resault // 1 => <div><a href...>hello world</a></div>// 2 => <div>hello world</div>
aotoo.list
const testlist = Aotoo Aotoo // resault // <ul>// <li>hello</li>// <li>world</li>// <li>agzgz</li>// </ul>
aotoo.tree
const testtree = Aotoo Aotoo // resault // <ul>// <li> // class=level-0 <span>hello</span> ul li // class=level-1 span // world ul li // class=level-2 span // you are ul li // beautiful class=level-3 </li>// <li>agzgz</li>// </ul>
aotoo.wrap
wrap Jsx dom
// case 1 const testdiv = <div><span ="agzgz">hello world<span></div> const NewReactClass = aotoo aotoo // case 2 const testdiv = <div><span ="agzgz">hello world<span></div> const NewReactClass = aotoo aotoo
wrap react class
Component { ... } { return // ...some jsx dom } // case 1 const NewReactClass = aotoo // case 2 const NewReactClass = aotoo aotoo
aotoo.transTree
// the data as follow that will be translated to .... // beforedata: title: 'hello' idf: 'root' // title support String or Jsx dom title: 'world' parent: 'root' idf: 'second' title: 'you are' parent: 'second' idf: 'third' title: 'beautiful' parent: 'third' title: 'agzgz' attr: id: 'index' // after/*data: [ { title: 'hello', li:[ {title: 'world', li: [ {title: 'you are', li:[ {title: 'beautiful'} ]} ]} ]}, { title: 'agzgz', attr: {id: 'index'}}]*/ // and then will be resolved to jsx dom with multi-layer