Hi All,
Firstly, thank you for your work on bridging the (huge) gap between the React & NPM and Rails ecosystems - being able to structure applications in this way will be immensely helpful.
I am currently writing a new application using Rails 5 and React_on_Rails 6.0.1, however have run into some issues registering react components - namely, the following error.
Could not find component registered with name UserHeader.
Registered component names include [ HelloWorldApp ].
Maybe you forgot to register the component?
My client directory is currently structured as follows:
- client
- app
- bundles
- UserHeader
- components
- UserHeader.jsx
- startup
- Registration.jsx
I have defined my UserHeader
component using ES6, as per the HelloWorldApp example, and am registering my component as follows:
console.log("Registering user header component...");
import React from 'react';
import ReactOnRails from 'react-on-rails';
import UserHeaderWidget from '../components/UserHeader'
const UserHeader = (props, _railsContext) => {
return <UserHeaderWidget {...props} />
};
ReactOnRails.register({ UserHeader });
I’m attempting to render this component from a rails partial, located in app/views/layouts/partials
, as follows:
<%= react_component('UserHeader', props: @user, prerender: true) unless @user.nil? %>
Interestingly, the console.log()
call in Registration.jsx
is not invoked.
I suspect I’m missing something rather obvious, but can’t for the life of me work out what.
Any help is greatly appreciated.
Thanks!