Created by: haraldrudell
fix for #3481 (closed)
test by adding Babel Function bind transform:
- run create-react-app
npm i --save-dev babel-plugin-transform-function-bind
- add to package.json:
"create-react-app": {
"babel": {
"plugins": [
"transform-function-bind"
]
}
},
- modify src/App.js to use the experimental bind operator:
class App extends Component {
constructor(o) {
super(o)
const thisf = ::this.f // this.f.bind(this) in ancient ECMAScript 2017
const actualThis = thisf() // if bind no work: undefined
const isCorrect = this.isCorrect = this === actualThis
console.log(`this correct: ${isCorrect}`)
}
f() {
return this
}
render() {
return (
<div className="App">bind operator working: {String(this.isCorrect)}
verify that npm t and npm start still works…
Awesome!