I have implemented SSR in my website using the react-dom/server . Every thing is working but because of not availability of window and document object in the server a animation library mojs is not working at all . I tried to change the source code at mo.js to change it from undefined to { } like this
if (!process.env.BROWSER) {
global.window = {}; // Temporarily define window for server-side
global.document = {};
}
but because of that thousands other error are coming. Is there any solution to work here. I am using the npm package for mojs .
What do you mean "thousands of errors"? What is your stack?
Girish Patil
Full-stack engineer
I dont know whats your exact situation but am guessing here.
Why not handle
mojsonly on the clientside. If you want to initiate it, run it insidecomponentDidMount()which only runs on client side.To be more clear, Place a screenshot of the log or detail the problem.