unabridged / motion

Reactive frontend UI components for Rails in pure Ruby
https://github.com/unabridged/motion
MIT License
697 stars 19 forks source link

Motion does not work with Rails 7.1.4? marshal_dump and "one root element" spurious errors? #175

Open swombat opened 1 week ago

swombat commented 1 week ago

If I take a ViewComponent that works and I add:

  include Motion::Component

Then immediately I get an error that private method 'marshal_dump' called for an instance of MyComponent.

I shouldn't need to, but let's say I create some marshalling methods like:

  def marshal_dump
    [@object, @header, @body, @property, @params, @value, @value_timestamp]
  end

  def marshal_load(array)
    @object, @header, @body, @property, @params, @value, @value_timestamp = array
  end

Then the next error I get is that:

The template for MyComponent can only have one root element.

Hint: Wrap all elements in a single element, such as `<div>` or `<section>`.

This is even though there is indeed just a single <div> component at the root.

I am also running BulletTrain on this app, but this occurs also if you set up a fresh app.

Steps:

  1. set up new rails app (7.1.4)
  2. create a test route/view
  3. install view_components and motion (incl yarn and setup task)
  4. copy the CalculatorComponent from the demo project
  5. try to render it

Result:

private method `marshal_dump' called for an instance of CalculatorComponent

As far as I can tell, Motion does not work with Rails 7.1.4.

Thoughts?