1.0.1 • Published 8 years ago
kamponent v1.0.1
kamponent
a component for creating react components :running:
This library is not released yet
Installation
npm:
npm install kamponent --saveyarn:
yarn add kamponentExample 1
<Kamponent pure initialState={{ count: 0 }}>
{({ state, setState }) => {
return (
<div>
<h3>{state.count}</h3>
<button onClick={() => setState({ count: state.count + 1 })}>+</button>
<button onClick={() => setState({ count: state.count - 1 })}>-</button>
</div>
);
}}
</Kamponent>Example 2
<Kamponent>
{({ props }) => {
return (
<div>
<h3>{props.count}</h3>
<button onClick={() => props.increment()}>+</button>
<button onClick={() => props.decrement()}>-</button>
</div>
);
}}
</Kamponent>props
| Property | Type | Working |
|---|---|---|
| children | function or array or object | Yes |
| initialState | object | Yes |
| pure | bool | Yes |
| didMount | function | Yes |
| didCatch | function | Yes |
| willUnmount | function | Yes |
| shouldUpdate | function | Yes |
| didUpdate | function | Yes |
| snapshotBeforeUpdate | function | Yes |
params in functions
note: you can access to this parameters from functions and children (if it be function).
| Property | Type | Working |
|---|---|---|
| state | any | Yes |
| props | any | Yes |
| setState | function | Yes |
| forceUpdate | function | Yes |