-
Notifications
You must be signed in to change notification settings - Fork 306
/
ExternalReactState.tsx
29 lines (27 loc) 路 831 Bytes
/
ExternalReactState.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { cloneDeep, mapValues } from 'lodash'
import * as React from 'react'
import { FlowChart } from '../src'
import * as actions from '../src/container/actions'
import { Page } from './components'
import { chartSimple } from './misc/exampleChartState'
/**
* State is external to the <FlowChart> Element
*
* You could easily move this state to Redux or similar by creating your own callback actions.
*/
export class ExternalReactState extends React.Component {
public state = cloneDeep(chartSimple)
public render () {
const chart = this.state
const stateActions = mapValues(actions, (func: any) =>
(...args: any) => this.setState(func(...args))) as typeof actions
return (
<Page>
<FlowChart
chart={chart}
callbacks={stateActions}
/>
</Page>
)
}
}