使用給出的React-Bootstrap和react.rb的例子完美的工作,但我試圖得到一個名爲React-TimeAgo的NPN組件工作,我迷路了。如何將基於JavaScript或JSX的組件導入React.rb,以便在Ruby中可訪問?
這是我做了什麼:
在index.js(爲的WebPack將其導入到的WebPack束):
window.bs = require('react-bootstrap')
window.timeago = require('react-timeago')
在實際component.rb我有這樣的:
class Rb < React::NativeLibrary
imports 'bs'
end
class TimeAgo < React::NativeLibrary
imports 'timeago'
end
然後引用引導部件完美地工作:
Rb.Button(bsStyle: :primary) <- works as expected
,但我不設法得到什麼的TIMEAGO包裝的:
TimeAgo.new(date: "Aug 29, 2014") {} <- just does nothing
TimeAgo(date: "Aug 29, 2014") {} <- method undefined
我在做什麼錯?所有幫助讚賞!
嘗試TimeAgo :: TimeAgo(date:「2014年8月29日」) –
也在js控制檯中嘗試查看Opal.TimeAgo,看看裏面有什麼 –