Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After #3395 started facing SSR infinite render loop that leads to "Maximum call stack size exceeded" #3448

Closed
andrew-bn opened this issue Jul 6, 2022 · 3 comments · Fixed by #3453
Labels

Comments

@andrew-bn
Copy link

andrew-bn commented Jul 6, 2022

After fix #3395 started getting stack overflow during SSR.
Am I doing something wrong?

Using:
"react": "^18.2.0",
"mobx": "^6.6.1",
"mobx-react": "^7.5.1"
"typescript": "^4.7.4".

TypeScript options

    "experimentalDecorators": true,
     "useDefineForClassFields": true,

Test component

import React from "react";
import {observer} from "mobx-react";

@observer
export class TestControl extends React.Component {

    render() {
        return ":)";
    }
}

Rendering

//...
import {configure} from "mobx";
import { enableStaticRendering } from "mobx-react";
//...
// configuring for ssr
configure({enforceActions: "never"});
enableStaticRendering(true); // if keep 'false' then all works, but is not recommended for SSR

//... somewhere during rendering
let elem = <TestControl/>;
result = ReactDOMServer.renderToString(elem); 

Infinite loop occurs in observerClass.ts

    target.render = function () {
        if (!isUsingStaticRendering()) {
            this.render = createReactiveRender.call(this, originalRender)
        }
        return this.render() // during this call again entering same render function
    }
@mweststrate
Copy link
Member

Looks like that should be return originalRender.call(this) indeed if I read things correctly? cc @urugator. Feel free to put up a PR.

@andrew-bn
Copy link
Author

return originalRender.call(this)

Looks like this will not help. Need a contribution from @urugator . Right now just switching back to working revision 7.5.0

@urugator
Copy link
Collaborator

urugator commented Jul 6, 2022

#3452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants