acdlite / acdlite/realm

Allow stateless view component

未關閉
#2 0 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
JavaScript
星號
170
分支
5
PR 合併指標
30 天內沒有已合併 PR

描述

I tried to run the example in `README.md` but i got:

```
warning.js:45 Warning: view(...): No `render` method found on the returned component instance: you may have forgotten to define `render`, returned null/false from a stateless component, or tried to render an element whose type is a function that isn't a React component.warning @ warning.js:45ReactCompositeComponentMixin.mountComponent @ ReactCompositeComponent.js:166ReactCompositeComponent_mountComponent @ ReactPerf.js:66ReactReconciler.mountComponent @ ReactReconciler.js:37ReactCompositeComponentMixin.mountComponent @ ReactCompositeComponent.js:225ReactCompositeComponent_mountComponent @ ReactPerf.js:66ReactReconciler.mountComponent @ ReactReconciler.js:37ReactCompositeComponentMixin.mountComponent @ ReactCompositeComponent.js:225ReactCompositeComponent_mountComponent @ ReactPerf.js:66ReactReconciler.mountComponent @ ReactReconciler.js:37mountComponentIntoNode @ ReactMount.js:266Mixin.perform @ Transaction.js:136batchedMountComponentIntoNode @ ReactMount.js:282Mixin.perform @ Transaction.js:136ReactDefaultBatchingStrategy.batchedUpdates @ ReactDefaultBatchingStrategy.js:62batchedUpdates @ ReactUpdates.js:94ReactMount._renderNewRootComponent @ ReactMount.js:476ReactMount__renderNewRootComponent @ ReactPerf.js:66ReactMount._renderSubtreeIntoContainer @ ReactMount.js:550ReactMount.render @ ReactMount.js:570React_render @ ReactPerf.js:66(anonymous function) @ app.js:92(anonymous function) @ app.js:94(anonymous function) @ app.js:95(anonymous function) @ bundle.js:1007__webpack_require__ @ bundle.js:521fn @ bundle.js:76(anonymous function) @ multi_main:3(anonymous function) @ bundle.js:551__webpack_require__ @ bundle.js:521(anonymous function) @ bundle.js:544(anonymous function) @ bundle.js:547
ReactCompositeComponent.js:587 Uncaught TypeError: inst.render is not a function
```

so replaced the stateless component with:

```
class view extends React.Component {
render(){
const { model, dispatch } = this.props
return (


Count: {model}


dispatch({ type: INCREMENT }) }>+
dispatch({ type: DECREMENT }) }>-

)
}
}
```

and it worked.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。