Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Getting an error server side rendering a withState component #581

Open
abhiaiyer91 opened this issue Dec 28, 2017 · 5 comments
Open

Getting an error server side rendering a withState component #581

abhiaiyer91 opened this issue Dec 28, 2017 · 5 comments

Comments

@abhiaiyer91
Copy link

Hello!

I have a component that uses withState like so:

withState('item', 'setItem', ({ val }) => {
  return val;
})

Having upgraded to recompose 0.26.0 and React 16.2.0, i'm getting an error here

https://github.com/acdlite/recompose/blob/master/src/packages/recompose/withState.js#L21

Where my app is destructuring stateValue, but in the case I'm experiencing prevState is null!

does React guarantee prevState as an object?

Any ideas?

@pokorson
Copy link
Contributor

pokorson commented Jan 4, 2018

@abhiaiyer91 are you sure you're passing correct props for the component? and it's not getting null for first render?

@istarkov
Copy link
Contributor

istarkov commented Jan 4, 2018

Real example? As stateValue is always defined for state https://github.com/acdlite/recompose/blob/master/src/packages/recompose/withState.js#L12-L13

@panayi
Copy link

panayi commented Mar 14, 2018

Getting the same error on server-rendering with after.js

@wuct
Copy link
Contributor

wuct commented Mar 19, 2018

@panayi can you provide some example code to reproduce the issue?

@paulussimanjuntak
Copy link

Hi, i'm want to ask is there a way that does not cause errors to use withState more than 1 time?
Screen Shot 2020-06-05 at 17 28 36
and can you provide an example?
thankyou

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants