1.0.1 • Published 6 years ago

kamponent v1.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

kamponent

a component for creating react components :running:

This library is not released yet

Installation

npm:

npm install kamponent --save

yarn:

yarn add kamponent

Example 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

PropertyTypeWorking
childrenfunction or array or objectYes
initialStateobjectYes
pureboolYes
didMountfunctionYes
didCatchfunctionYes
willUnmountfunctionYes
shouldUpdatefunctionYes
didUpdatefunctionYes
snapshotBeforeUpdatefunctionYes

params in functions

note: you can access to this parameters from functions and children (if it be function).
PropertyTypeWorking
stateanyYes
propsanyYes
setStatefunctionYes
forceUpdatefunctionYes