5 ms·
Is there a convincing Stimulus vs. React-Rails post anywhere?
by shay_ker 6y ago
Is there a convincing Stimulus vs. React-Rails post anywhere?
- newsbinator 6y agoOr a convincing Stimulus vs. Vue post would be helpful too, since Vue is so simple to sprinkle in as well, and doesn't pollute the html with data attributes as much as Stimulus.
- mike1o1 6y agoOne benefit is when combined with Turbolinks there is a need to bootstrap the Vue/React component. The Stimulus controllers respond to mutation observers and always work. If a new HTML element is added to the DOM and has a controller, it just works and is now active. This might not be the case with React or Vue, as you'd have to then bootstrap the component. This makes Stimulus a really good combo when used with Turbolinks or partial Javascript responses.
- phaedryx 6y agoI switched from Stimulus to Vue and have had a much better experience so far. It is much easier for me to use and I still get the value of "sprinking"
- Scarbutt 6y agoStimulus is paired with Turbolinks, which doesn't play well with almost anything in the JS ecosystem.
- deedubaya 6y agoThis used to be accurate in the days of auto initializing jquery plugins, but probably isn’t the case today if you’re actually using stimulus.
- hfourm 6y agoIt still is problematic if you use third party plugins / saas vendors. Not all. But many. Things like zendesk integrations for example. YMMV
- Toutouxc 6y agoStimulus has nothing to do with Turbolinks.
- swanson 6y agoThey are both JS frameworks, but they are fundamentally different approaches. React (and React-rails) moves rendering / state / logic clientside. You can use tools like react-rails to more easily pass data from your Rails controller to your react components (basically conveniences to create props from instance variables). Stimulus doesn't handle rendering at all. It's intended to be used for small little "sprinkles" of JavaScript (think things like: showing / hiding content, toggling classes, basic event handlers). If you used to write jQuery snippets to wire up a click event to run ~5-10 lines of JS, then you might look at Stimulus as a more modern implementation (es6, mutationobserver, etc). Stimulus plays nicely with Turbolinks since it needs existing HTML (servered rendered from normal Rails views) to attach to. You're basically looking at two diverging paths: do you go down a JS-driven SPA application with React (or some kind of hybrid where you have React do parts of the page) or do you opt for Basecamp's "I cant belive its not a SPA" approach with Turbolinks, server-rendered HTML, and Stimulus for small interactivity. Here's a talk I gave at the London Ruby meetup about Stimulus and in what contexts you might want to use (or not use it): https://assets.lrug.org/videos/2020/september/matt-swanson-stimulusjs-modest-js-for-the-html-you-have-lrug-sep-2020.mp4 https://assets.lrug.org/videos/2020/september/matt-swanson-s...
- dsego 6y agoWhat you are describing seems similar to good old BackboneJS?
- Lio 6y agoNot sure about react-rails but using Stimulus as part of StimulusRelex[1] is super interesting to me. 1. https://docs.stimulusreflex.com/ https://docs.stimulusreflex.com/