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
wheel/app/views/home/index.html.erb
Line 1 in b980f3a
Second entry point
wheel/app/javascript/packs/application.js
Line 20 in b980f3a
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.