Server Side Rendering
When using server side rendering, the components are rendered only once. Since components are never unmounted, observer components would in this case leak memory when being rendered server side.
To avoid leaking memory, call useStaticRendering(true)
when using server side rendering which essentially disables observer.
import { useStaticRendering } from 'mobx-react'
// use whatever condition you want/need, this is just an example
if (process.env.SSR) {
useStaticRendering(true)
}
Note: Despite the naming, the function IS NOT A REACT HOOK. The name was decided long before the React Hooks were introduced. You should call it only once at the root of your server side code.
当前内容版权归 mobx-react 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mobx-react .