{"action":"created","issue":{"url":"https://api.github.com/repos/reactjs/react-rails/issues/514","repository_url":"https://api.github.com/repos/reactjs/react-rails","labels_url":"https://api.github.com/repos/reactjs/react-rails/issues/514/labels{/name}","comments_url":"https://api.github.com/repos/reactjs/react-rails/issues/514/comments","events_url":"https://api.github.com/repos/reactjs/react-rails/issues/514/events","html_url":"https://github.com/reactjs/react-rails/issues/514","id":149132052,"number":514,"title":"TypeError: undefined not a function; Using mixin in react component","user":{"login":"sahil-23","id":6543013,"avatar_url":"https://avatars.githubusercontent.com/u/6543013?v=3","gravatar_id":"","url":"https://api.github.com/users/sahil-23","html_url":"https://github.com/sahil-23","followers_url":"https://api.github.com/users/sahil-23/followers","following_url":"https://api.github.com/users/sahil-23/following{/other_user}","gists_url":"https://api.github.com/users/sahil-23/gists{/gist_id}","starred_url":"https://api.github.com/users/sahil-23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sahil-23/subscriptions","organizations_url":"https://api.github.com/users/sahil-23/orgs","repos_url":"https://api.github.com/users/sahil-23/repos","events_url":"https://api.github.com/users/sahil-23/events{/privacy}","received_events_url":"https://api.github.com/users/sahil-23/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-18T12:06:34Z","updated_at":"2016-04-18T16:20:28Z","closed_at":null,"body":"Help us help you! Please choose one:\r\n\r\n- [ ] My app crashes with `react-rails`, so I've included the stack trace and the exact steps which make it crash.\r\n- [ ] My app doesn't crash, but I'm getting unexpected behavior. So, I've described the unexpected behavior and suggested a new behavior.\r\n- [ ] I'm trying to use `react-rails` with another library, but I'm having trouble. I've described my JavaScript management setup (eg, Sprockets, Webpack...), how I'm trying to use this other library, and why it's not working.\r\n- [x] I have another issue to discuss.\r\n\r\n-------\r\n\r\nI have an issue when I am using a **mixin** in some react component. \r\n\r\nI have defined a **mixin** in some file, say **mixins.js** and using it in some react component defined in another file, say **react_component.js**. When using some mixin function in the react component, it is thowing error:\r\n> TypeError: undefined is not a function\r\n\r\nThe mixin is accessible from the react component as when I set prerender to false, the component is being rendered properly.\r\n\r\nAnother weird thing that's happening is when I include the mixin in **react_component.js** file above the react component, it works in backend rendering also.\r\n"},"comment":{"url":"https://api.github.com/repos/reactjs/react-rails/issues/comments/211452951","html_url":"https://github.com/reactjs/react-rails/issues/514#issuecomment-211452951","issue_url":"https://api.github.com/repos/reactjs/react-rails/issues/514","id":211452951,"user":{"login":"rmosolgo","id":2231765,"avatar_url":"https://avatars.githubusercontent.com/u/2231765?v=3","gravatar_id":"","url":"https://api.github.com/users/rmosolgo","html_url":"https://github.com/rmosolgo","followers_url":"https://api.github.com/users/rmosolgo/followers","following_url":"https://api.github.com/users/rmosolgo/following{/other_user}","gists_url":"https://api.github.com/users/rmosolgo/gists{/gist_id}","starred_url":"https://api.github.com/users/rmosolgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmosolgo/subscriptions","organizations_url":"https://api.github.com/users/rmosolgo/orgs","repos_url":"https://api.github.com/users/rmosolgo/repos","events_url":"https://api.github.com/users/rmosolgo/events{/privacy}","received_events_url":"https://api.github.com/users/rmosolgo/received_events","type":"User","site_admin":false},"created_at":"2016-04-18T16:20:28Z","updated_at":"2016-04-18T16:20:28Z","body":"It sounds like your mixin is not included in the server rendering manifest. \r\n\r\nBy default, only `components.js` is loaded on the server. So, if your mixin isn't required by that file, it won't be available on the server. \r\n\r\nTry adding to `components.js`: \r\n\r\n```\r\n//= require your_mixin_file\r\n```\r\n\r\n\r\nAlternatively, you could ensure the mixin is loaded by adding a `//= require` to the component itself, for example: \r\n\r\n```js \r\n//= require ../my_mixin_file \r\n\r\nvar MyComponent = React.createClas({ \r\n  // ... \r\n})\r\n```\r\n\r\nThat way, the mixin will be loaded _anywhere_ that the component is loaded. \r\n\r\nDoes that help?\r\n\r\n\r\n"}}