bigbinary / wheel

Don't reinvent the wheel for every new Rails project. Use sane Defaults.

Home Page:https://wheel-production.neetodeployapp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple react entry point

sritabh opened this issue · comments

There are more than one entry point for react components, which forces components to render twice.

First entry point

<%= react_component("App", get_client_props, { class: "root-container" }) %>

Second entry point

ReactRailsUJS.mountComponents();

Possible fix could be to remove second entry point.

ThemountComponents() function call is actually added to ensure that the components show up in React dev tools etc. I don't think we need to remove this call.

@Amaljith-K We are using the piece of code in neeto too: https://github.com/bigbinary/neeto-wheel-web/blob/main/app/javascript/packs/application.js#L21C1-L21C33. Have you experienced any double rendering issues as mentioned in the issue in neeto?

I haven't noticed the problem. I'll check again and will update.

I checked. Yes. There is a double render issue when we use ReactRailsUJS.mountComponents();.
But the renders happen so fast that we won't notice the difference.
We can remove ReactRailsUJS.mountComponents(); from application.js

@Amaljith-K I thought that statement was needed to make React dev tools work. If it's not needed anymore with Shackapacker then I guess we can remove that statement.

Everything works fine without that statement.
@ajmaln please make necessary changes in neeto products too.