Stimulus 3

world.hey.com
3 min read
standard
The third major release of Stimulus represents a big milestone for the Hotwire community. This is the first release where every substantial new feature came as a contribution from outside of Basecamp and HEY. We've got a new package, action parameters, default values, target lifecycle callbacks, debug mode, utility-CSS support, and Con...
New Package

First, Stimulus has moved from

Also, the Webpack helpers are now longer part of the main distribution. They now live separately under

Action Parameters

Often you need to invoke the same controller action from multiple places in your application. Before, if you want to specialize those invocations with arguments, you had to use the dataset on the submitter element, coming up with your own convention on naming and scoping. Now action parameters are built into Stimulus. They work like this:

The third major release of Stimulus represents a big milestone for the Hotwire community. This is the first release where every substantial new feature came as a contribution from outside of Basecamp and HEY . We've got a new package, action parameters, default values, target lifecycle callbacks, debug mode, utility-CSS support, and Controller.shouldLoad. Let's dig into what's new!First, Stimulus has moved from stimulus to @hotwired/stimulus on npm. The old package is still available as a proxy, but you should upgrade all your references, if you can.Also, the Webpack helpers are now longer part of the main distribution. They now live separately under @hotwired/stimulus-webpack-helpers Often you need to invoke the same controller action from multiple places in your application. Before, if you want to specialize those invocations with arguments, you had to use the dataset on the submitter element, coming up with your own convention on naming and scoping. Now action parameters are built into Stimulus. They work like this:

… class ItemController extends Controller { upvote({ params }) { // { id: 12345, url:…
Read full article