Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React, Ruby on Rails: jsx vs html.erb

I'm using the react-rails gem to integrate react with rails, and I'm conflicted on how I should organize my code.

Is it preferable that I have my core html in the html.erb files or in the jsx files? Currently, I basically made everything a component. All I do in my html.erb files is using the react_component helper to call those components. For example, I would have a ProfileShow.js.jsx file for my profile page and a EditPost.js.jsx for my edit post page.

What is your suggestion?

like image 926
Novice Avatar asked Nov 09 '22 04:11

Novice


1 Answers

I prefer move my react-component's code to js-files. And link them using react_component helper method. It isn't good practice to write your js-code in views.

like image 192
Sergei Stralenia Avatar answered Nov 14 '22 21:11

Sergei Stralenia