javascript - Rails and React, loading react-typeahead component with require -


i have react working rails using react-rails gem. rendering hellomessage component react front page fine.

i used bower install 'react-typeahead' (react-typeahead github)

var typeahead = require('react-typeahead').typeahead; 

the problem require not defined. i've looked requirejs-rails , browserify-rails, first requires stop using sprockets, , unable second working.

i'm new this, how should getting require work 'react-typeahead' component?

currently browserify getting:

error: cannot find module 'react-typeahead' '/users/xxx/code/xxx/app/assets/javascripts'     @ /users/xxx/code/xxx/node_modules/browserify/node_modules/resolve/lib/async.js:46:17 

even though installed in directory bower. i've double checked , matches path.

in require statement, need require exact path of library you're looking import if it's not in same folder, example:

error: cannot find module 'react-typeahead' '/users/xxx/code/xxx/app/assets/javascripts' @ /users/xxx/code/xxx/node_modules/browserify/node_modules/resolve/lib/async.js:46:17 

notice how it's looking in app/assets/javascripts, point towards node_modules folder.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -