diff --git a/demo/demos/WithHandlersDemo.tsx b/demo/demos/WithHandlersDemo.tsx new file mode 100644 index 0000000..24f972b --- /dev/null +++ b/demo/demos/WithHandlersDemo.tsx @@ -0,0 +1,32 @@ +import * as React from 'react'; +import { withState } from '../../src/lib/withState'; +import { ChainableComponent } from '../../src/ChainableComponent'; +import Step from '../Step'; +import { DoBuilder } from '../../src'; +import { withHandler } from '../../src/lib/withHandler'; + +export const WithHandlersDemo = + DoBuilder + .bind('b', withState(0)) + .bind('a', withState(0)) + .bindL('handler', ({a, b}) => { + console.log('handler', a.value, b.value) + return withHandler(() => alert(`A's count is : ${a.value}`), [b.value]) + }) + .done() + .render(({a, b, handler}) => ( +
+ {``} ++ {WithHandlersDemo} +