Does react server rendering have to use a state container such as redux?

problem description

I recently worked on a homogeneous react project, and my client is relatively simple and does not require a redux data container. Now the isomorphism uses server-side rendering, but the setState method in my client does not seem to work on the server side and will report an error.

Warning: setState(...): Can only update a mounting component. This usually means you called setState() outside componentWillMount() on theserver. This is a no-op.

what methods have you tried

so I guessed that there is no data container such as redux, which can not be used properly.


is not required to introduce redux. Did you put the setState into the componentDidMount when the component was initialized? ComponentDidMount is not executed during server rendering, only componentWillMount can, so setState should be put in componentWillMount

.
Menu