manual-bind-to-arrow
Convert constructor-time .bind(this) assignments into arrow class fields.
Usage
bash
Development
bash
Explore community-led codemods to migrate, optimize, and transform your codebase.
Build your own codemod and share it with the community.
Convert this.method = this.method.bind(this) to arrow class property
npx codemod @react-new/manual-bind-to-arrow
Convert constructor-time .bind(this) assignments into arrow class fields.
bash
bash
This is one example from the codemod's test cases. The codemod may handle many more cases.
Build your own codemod and share it with the community.
1 class Component extends React.Component {
2 constructor() {
3 super();
4 const self: any = this;
5 self._onMapResize = debounceCore(this._onMapResize.bind(this), 100);
6 self.onClick = this.onClick.bind(this);
7 }
8 onClick() { }
9 onMapResize() { }
10 }
11