You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently our project is using server-side rendering to build the initial marko components. While developing, our team came across an issue when using setState within the onInput method. On the server-side we get an error TypeError: this.setState is not a function, though browser works fine. My manager and I started talking and looking into the difference between the Component.js and ServerComponent.js. Seems any state change method is not implemented for the ServerComponent.js. A simple code example:
this.setState should not throw error when doing server rendering
Actual Behavior
this.setState throws error
Possible Fix
Implement state changing methods on ServerComponent.js (setSate, replaceState)
Additional Info
Your Environment
Environment name and version (e.g. Chrome 39, node.js 5.4):
**Chrome 64, nodejs 8.6.0
Operating System and version (desktop or mobile):
**Mac OS 10.13.3 Desktop
Stack Trace
TypeError: this.setState is not a function at Modal.onInput (webpack-internal:///54:37:22) at Modal.ServerComponent (webpack-internal:///47:20:37) at ServerComponent (webpack-internal:///46:11:5) at Object.createComponent [as ___createComponent] (webpack-internal:///46:24:21) at renderer (webpack-internal:///44:106:34) at wrappedRenderer (webpack-internal:///52:106:13) at render (webpack-internal:///51:21:3) at renderer (webpack-internal:///44:186:9) at safeRender (webpack-internal:///38:6:9) at Template.render (webpack-internal:///38:136:20)
The text was updated successfully, but these errors were encountered:
Bug Report
Marko Version: 4.5.6
Details
Currently our project is using server-side rendering to build the initial marko components. While developing, our team came across an issue when using
setState
within theonInput
method. On the server-side we get an errorTypeError: this.setState is not a function
, though browser works fine. My manager and I started talking and looking into the difference between the Component.js and ServerComponent.js. Seems any state change method is not implemented for the ServerComponent.js. A simple code example:component.js
On server-side render this causes the error.
Expected Behavior
this.setState
should not throw error when doing server renderingActual Behavior
this.setState
throws errorPossible Fix
Implement state changing methods on ServerComponent.js (
setSate
,replaceState
)Additional Info
Your Environment
**Chrome 64, nodejs 8.6.0
**Mac OS 10.13.3 Desktop
Stack Trace
TypeError: this.setState is not a function at Modal.onInput (webpack-internal:///54:37:22) at Modal.ServerComponent (webpack-internal:///47:20:37) at ServerComponent (webpack-internal:///46:11:5) at Object.createComponent [as ___createComponent] (webpack-internal:///46:24:21) at renderer (webpack-internal:///44:106:34) at wrappedRenderer (webpack-internal:///52:106:13) at render (webpack-internal:///51:21:3) at renderer (webpack-internal:///44:186:9) at safeRender (webpack-internal:///38:6:9) at Template.render (webpack-internal:///38:136:20)
The text was updated successfully, but these errors were encountered: