0
我無法找到此解決方案。我如何將下面的代碼轉換爲更加動態和簡潔的內容?動態生成React組件名稱
OneComponent = require ('./OneComponent')
TwoComponent = require ('./TwoComponent')
ThreeComponent = require ('./ThreeComponent')
Example = React.createClass
render: ->
filter = @props.filterState
if filter is 'something'
tableCmpt =
<div>
<OneComponent
tasks={@props.tasks}
/>
</div>
if filter is 'somethingElse'
tableCmpt =
<div>
<TwoComponent
tasks={@props.tasks}
/>
</div>
##... etc
return tableCmpt
感謝@Crob,這不會出現雖然要爲我工作。有什麼想法嗎?我註銷了'component' var,它似乎在抓取組件,但它並沒有實例化組件 – Ben