I am not fully understood React's Server Side Rendering.
What's difference behaviors occurred between two examples?
First
function Test() {
const context = useContext(AuthContext)
const { user } = context
return (
user ? <h1>User</h1> : <h1>No User</h1>
)
}
export default withApollo({ ssr: true })(Test)
===> Error occured Text content did not match. Server: "No User" Client: "User"
Second
function Test() {
const context = useContext(AuthContext)
const [ user, setUser ] = useState(null)
useEffect(() => {
setUser(context.user)
}, [])
return (
user ? <h1>User</h1> : <h1>No User</h1>
)
}
export default withApollo({ ssr: true })(Test)
===> No Error.
What's difference? Why the first one make error but second not? In Postman, when I request this component route for checking server side response, both's response are same (No User).
What point is make difference? useEffect only excuted in client side, I know, but how about first one also updated to No User to User. when is hydration point, render point ?