0

I have a simple functional component and would like to initialize the state with a boolean, depending on the condition. For example:

export default() => {

  const st = useSelector(state => state.body);
  const { type } = st;

  let bool = type === 'test'

  const [ hidden, setHidden ] = useState(bool) //this is always true

}

st is just fetching the state from redux, type will be condition. In some cases type will be test so bool will be true, but when it's initializing the state it's always false.

I do a console.log after the useState and hidden displays false???

I'm not sure what's causing to be false. Am i missing something? I appreciate your help and insights

1 Answers

MA==
}w 2nZl+#_z!x--jןy۱ۖ$-zȬirzom)kzw^
ʋzkazay+-nzmz{(u+r^w^~)w(u
lyږ~^֭yןj[
jwmj^Ƭy'vuފ޶^ryoj[
np{ky, --j׿yןjmnzܡ׮j׿r^)em)kzw^
jwb~)kzw^+b{pr
(!jx
y^̨ǭhZ*.ru"r^DŽ}(uhKhzur^r^*^yZkyyi]y-rn䞕--jנZw'(mʗWn%*^-}ly'buק
*^
G^(u