Allow stateless view component
- Vorherrschende Sprache
- JavaScript
- Sterne
- 170
- Forks
- 5
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Reproduce the failure using the README example and the `app.js` entrypoint referenced in the trace so you can confirm the render-path error. Then inspect the library’s view/component mounting code path where it calls `render()` on the mounted instance, and adjust it to accept stateless function components. Run the same example flow again and confirm that the warning and `inst.render is not a function` TypeError do not appear when a stateless `view` is used.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, react
- Bereich
- frontend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 46/100