I created example project react-rails with webpacker. but show error "Uncaught ReferenceError: Person is not defined". help me How use react-rails with webpacker? The processing I performed is as follows.
Rails version
$ rails -v
Rails 5.0.2
Gem version
react-rails (2.1.0)
webpacker (1.1)
Create Rails project
$ rails new example
Add webpacker and react-rails to Gemfile
gem 'webpacker', github: 'rails/webpacker'
gem "react-rails"
Install webpacker and react
$ rails webpacker:install
$ rails webpacker:install:react
$ rails generate react:install
Create controller
$ bin/rails g controller home
Add route
config/routes.rb
root "home#index"
Add react component
$ bin/rails g react:component person name --es6
Add react_component tag
app/views/home/index.html.erb
<%= react_component("Person", { name: "Hello" }) %>
Add javascript_pack_tag to application.html.erb
app/views/layouts/application.html.erb
<%= javascript_pack_tag 'application' %>
Run server
$ bin/rails s
$ bin/webpack-dev-server
Show error console
VM27375:1 Uncaught ReferenceError: Person is not defined
at eval (eval at module.exports (fromGlobal.js?fc31:13), <anonymous>:1:1)
at module.exports (fromGlobal.js?fc31:13)
at Object.getConstructor (fromRequireContextWithGlobalFallback.js?cbbb:16)
at Object.mountComponents (index.js?c0e8:82)
at HTMLDocument.ReactRailsUJS.handleMount (index.js?c0e8:124)
at HTMLDocument.dispatch (jquery.self-bd7ddd3….js?body=1:5227)
at HTMLDocument.elemData.handle (jquery.self-bd7ddd3….js?body=1:4879)
example project