How to install react 18 in a Ruby on Rails 6 application
This is my current environment
Rails 220.127.116.11 ruby 2.7.2p137 Deepin OS 20.7.1 webpacker: ^5.4.4
In case you want to double-check yours, try the following commands
rails -v ruby -v lsb_release -a cat package.json | grep webpacker
webpacker:install:react is a Rails command that is used to install and configure the React framework with Webpacker in a Rails application.
webpacker:install:react, you can set up the necessary dependencies, configurations, and boilerplate files to start using React in your Rails application with Webpacker.
It simplifies the process of integrating React into the asset pipeline and provides a foundation for building React components within your Rails application.
In order to check the installation, choose one view file and add the following command in one place that you know how to locate it.
When the view template is rendered and the
<script> tag with the appropriate
When running your rails app, you should be able to see the following message:
cat package.json | grep react
cat command is used to concatenate and display the contents of a file. In this case, it displays the contents of the
package.json file in the terminal.
grep command is used to search for a specified pattern in the given input. In this case, it searches for the word "react" in the output of
So, when you run
cat package.json | grep react, the cat command displays the content of the package.json file, and the grep command filters that output to only show lines that contain the word "react".
The output will display any lines from the package.json file that include the word "react", such as dependencies or configuration related to React.
YOu should see something like this as a result
Let's become business friends
I hope this article helped you. Let me know if you need help.
Your thoughts, suggestions and corrections are more than welcome.
By the way, feel free to drop your suggestions on new blog articles.
Hope to see you next time.