Skip to content

Addons not being loaded to global state #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
davidlormor opened this issue Jan 21, 2016 · 3 comments
Closed

Addons not being loaded to global state #447

davidlormor opened this issue Jan 21, 2016 · 3 comments

Comments

@davidlormor
Copy link

This appears to be a similar issue to #315. Configuration and everything was set up correctly just like the previous issue, but when trying to use ReactCSSTransitionGroup in a component (defined in app/assets/javascripts/admin/components) I get a the following error in the browser console:

Uncaught ReferenceError: ReactCSSTransitionGroup is not defined

I can find the "development_with_addons" react file being loaded, but apparently the addon components being defined in this file are not being loaded to the global state for other components to use.

Adding var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup; to application.js resolves the issue. Just wonder if there's a cleaner/more automated way to ensure that all components are being required on load?

@rmosolgo
Copy link
Member

Yep, it's intentional that they're exposed on React.addons right now. That's the way the "official" react bundle does it (eg, https://fb.me/react-with-addons-0.14.6.min.js), and besides that, that's how it was when I started working on it, so I don't want to break it for people :P

I'd also love to see a more flexible & powerful way to load those things. You can see the existing build setup here: https://github.com/reactjs/react-rails/tree/master/react-builds. The addons object is created in addons-object, then tacked on to React.

I think it'd be nice to pick-and-choose your addons with //= require. Some people also requested making it more require-js friendly (although that doesn't apply to me personally).

@rmosolgo
Copy link
Member

You can get them from React.addons either by adding addons = true in config, or requiring them one-at-a-time (see the bottom of https://github.com/reactjs/react-rails#reactjs-builds)

Hope that helps!

@quangv
Copy link

quangv commented Feb 28, 2016

Thanks @davidlormor for the question and @rmosolgo for the clarification!

Just to be clear for anyone else running across this problem.

You'll need config.react.addons = true in application.rb and

`<React.addons.CSSTransitionGroup ... >
</React.addons.CSSTransitionGroup/>`

I couldn't get a-la-carte to work either. c18aa38

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

No branches or pull requests

3 participants