A Babel plugin that automatically binds all class methods to the instance, ensuring `this` context is preserved in callbacks. Version 5.0.1 supports hot reloading with React Hot Loader 3-beta. Unlike manual binding or property arrow functions, this plugin transforms code at build time with zero runtime overhead. It works with ES2015+ class syntax and is commonly used in React projects to avoid repetitive .bind(this) calls. The plugin is stable but not actively maintained; alternative patterns like class property arrow functions are preferred in modern codebases.
npm install babel-plugin-autobind-class-methodsVerified import paths — ran on the pinned version, not inferred.
Install plugin, add to Babel config, and see autobinding in action with a class method callback.
Use native class property syntax with arrow functions or explicitly bind in the constructor.
Check Babel version; for Babel 7 use @babel/plugin-proposal-class-properties or similar.
Do not mix autobind with arrow property methods; use one approach consistently.
Consider using selective binding via decorators or manual binding for performance-critical methods.
Migrate to modern class property syntax or use @babel/plugin-proposal-class-properties.
npm install babel-plugin-autobind-class-methods --save-dev
Ensure the plugin is listed in the 'plugins' array and not 'presets'.
Use @babel/plugin-proposal-class-properties instead or stick with Babel 6.
Ensure hot loader is correctly set up; see React Hot Loader 3-beta docs.
Disable the ESLint rule or adjust class constructor order.