a component for creating react components 🏃
npm:
npm install kamponent --save
yarn:
yarn add kamponent
<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>
<Kamponent>
{({ props }) => {
return (
<div>
<h3>{props.count}</h3>
<button onClick={() => props.increment()}>+</button>
<button onClick={() => props.decrement()}>-</button>
</div>
);
}}
</Kamponent>
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 |
Property | Type | Working |
---|---|---|
state | any | Yes |
props | any | Yes |
setState | function | Yes |
forceUpdate | function | Yes |