react-rails icon indicating copy to clipboard operation
react-rails copied to clipboard

Permanent Turbolinks components without a specified cache ID will be loaded for all components without a cache ID

Open joeyparis opened this issue 4 years ago • 1 comments

Help us help you! Have you looked for similar issues? Do you have reproduction steps? Contributing Guide

Steps to reproduce

<%= react_component "MyComponent", {prop_a: 1}, {data: {"turbolinks-permanent": true}}  %> <!-- Renders correctly -->
<%= react_component "MyOtherComponent", {prop_b: 2}  %> <!-- Renders "MyComponent" with "prop_a" instead of "MyOtherComponent" with "prop_b" -->

(Guidelines for creating a bug report are available here)

Expected behavior

Tell us what should happen

The later call to render MyOtherComponent should render MyOtherComponent and not MyComponent.

Actual behavior

Tell us what happens instead

Because the react-cache-id data attribute is not specified but turbolinks-permanent is set to true the component is cached under the key undefined. So any other components that are rendered after that component which also has react-cache-id undefined will instead use the incorrectly cached component, regardless of turbolinks-permanent being defined or not

System configuration

Sprockets or Webpacker version: Sprockets 3.7.2, Webpacker 4.0.7 React-Rails version: 2.6.0 Rect_UJS version: Unknown Rails version: 5.2.3 Ruby version:2.3.8p459

joeyparis avatar Sep 20 '19 15:09 joeyparis

I can take a stab at it.

ivnflpz avatar Oct 08 '19 05:10 ivnflpz

@ivnflpz @joeyparis, Any updates on this issue? Closing it for now. Feel free to reopen it.

alkesh26 avatar Nov 07 '22 08:11 alkesh26