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
I thought to give Preact a try. The pure approach.
Currently it seems everything is working smoothly, EXCEPT that render(props, state) behaviour described in Preact docs
Components also have a render() method, but unlike React this method is passed (props, state) as arguments. This provides an ergonomic means to destructure props and state into local variables to be referenced from JSX.
gets broken, meaning - no props and state is passed in render.
Expected behavior
render(props,state){const{counter}=state;return(<div><h3>{`ComponentPreact`}</h3><p>{`Current count is ${counter}`}</p></div>);}
should render counter.
Actual behavior
state in render(props, state) {} is undefined.
ComponentPreact.js?636f:113 Uncaught (in promise) TypeError: Cannot destructure property `counter` of 'undefined' or 'null'.
at ProxyComponent.render (ComponentPreact.js?636f:108)
at ProxyComponent.hotComponentRender (react-hot-loader.development.js?c2cb:622)
at ProxyComponent.proxiedRender (react-hot-loader.development.js?c2cb:630)
at renderComponent (preact.esm.js?30bf:728)
at setComponentProps (preact.esm.js?30bf:676)
at buildComponentFromVNode (preact.esm.js?30bf:842)
at idiff (preact.esm.js?30bf:397)
at innerDiffNode (preact.esm.js?30bf:516)
at idiff (preact.esm.js?30bf:439)
at diff (preact.esm.js?30bf:348)
Thus props and state are not passed into render function. Forgetting about method args and manually destructuring of course works =>
render(){const{counter}=this.state;return(<div><h3>{`ComponentPreact`}</h3><p>{`Current count is ${counter}`}</p></div>);}
Actually I don't mind 😆 as I'm used destructuring only what is needed out of state and props in render function anyway and const {a, b, c} = this.state; comes naturally.
Anyways, it seems that RHL breaks this Preact feature. Either it needs to be documented ar maybe it can be fixed. I have no idea what happens in preact-compat.
Environment
React Hot Loader version: 4.3.0
preact: 8.2.9
Run these commands in the project folder and fill in their results:
Description
I thought to give Preact a try. The pure approach.
Currently it seems everything is working smoothly, EXCEPT that
render(props, state)
behaviour described in Preact docsgets broken, meaning - no props and state is passed in render.
Expected behavior
should render counter.
Actual behavior
state
inrender(props, state) {}
is undefined.Thus
props
andstate
are not passed into render function. Forgetting about method args and manually destructuring of course works =>Actually I don't mind 😆 as I'm used destructuring only what is needed out of state and props in render function anyway and
const {a, b, c} = this.state;
comes naturally.Anyways, it seems that RHL breaks this Preact feature. Either it needs to be documented ar maybe it can be fixed. I have no idea what happens in
preact-compat
.Environment
React Hot Loader version: 4.3.0
preact: 8.2.9
Run these commands in the project folder and fill in their results:
node -v
: v8.11.2npm -v
: 6.1.0Then, specify:
.babelrc
defining the hotness
launching the hotness
Thanks! 🙇
The text was updated successfully, but these errors were encountered: