File tree 1 file changed +3
-3
lines changed
1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -70,8 +70,8 @@ class Switcher extends React.Component {
70
70
}
71
71
```
72
72
73
- The other alternative is to use arrow functions for the onClick prop function assignment,
74
- Arrow functions auto binds the function with ` this ` .
73
+ The other alternative is to use arrow functions for the onClick prop function assignment.
74
+ Arrow functions don't affect the context at invocation time ( ` this ` value from the surrounding scope is used) .
75
75
76
76
Facebook by the way recommend the same technique while dealing with functions that need the context of the same component.
77
77
The binding in the constructor may be also useful if we pass callbacks down the tree.
@@ -93,4 +93,4 @@ class Switcher extends React.Component {
93
93
console .log (` Button is clicked inside ${ this .state .name } ` );
94
94
}
95
95
}
96
- ```
96
+ ```
You can’t perform that action at this time.
0 commit comments