Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a157b9

Browse files
remove constructor
1 parente9a311a commit1a157b9

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

‎src/withStatechart.js‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,9 @@ const withStatechart = (statechart, options = {}) => Component => {
99
classStateMachineextendsReact.Component{
1010
machine=statechartinstanceofStateNode ?statechart :Machine(statechart)
1111

12-
lastEvent=null
13-
14-
constructor(props){
15-
super(props)
16-
17-
constmachineState=
18-
this.props.initialMachineState||this.machine.initialState
19-
20-
this.state={
21-
componentState:this.props.initialData,
22-
machineState,
23-
}
24-
25-
this.handleRef=!isStateless(Component) ?this.handleRef :null
12+
state={
13+
componentState:this.props.initialData,
14+
machineState:this.props.initialMachineState||this.machine.initialState,
2615
}
2716

2817
getChildContext(){
@@ -111,10 +100,12 @@ const withStatechart = (statechart, options = {}) => Component => {
111100
this.isTransitioning=false
112101
}
113102

114-
handleRef=element=>{
103+
setInstance=element=>{
115104
this.instance=element
116105
}
117106

107+
handleRef=!isStateless(Component) ?this.setInstance :null
108+
118109
handleTransition=(event,updater)=>{
119110
invariant(
120111
!this.isTransitioning,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp