Skip to content

Conversation

MiguelSavignano
Copy link

@MiguelSavignano MiguelSavignano commented Dec 23, 2017

I do not understand why I can not register a component with the name you want

Example:
I want to register HelloWorld component with the name "hello_world/index"

import ReactOnRails from 'react-on-rails'
import HelloWorld from '../../views/hello_world/index'
ReactOnRails.register({
  "hello_world/index": HelloWorld,
})
hello_world/index.html.erb
<%= react_component("hello_world/index", props: @hello_world_props, prerender: false) %>

When render the page react on rails say

ComponentRegistry.js:65 Uncaught Error: ReactOnRails encountered an error while rendering component: HelloWorld::Index.
Original message: Could not find component registered with name HelloWorld::Index. Registered

this error it's because react on rails camelize my component name.


This change is Reviewable

@justin808
Copy link
Member

Thank you @MiguelSavignano for trying to help.

We're keeping the code as-is because:

  1. The JavaScript standard is to use camelCase and not snake_case.
  2. This code has been there for over 2 years.
  3. Just change your registration. If others want this, I'd happily consider this change.

@justin808 justin808 closed this Dec 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants