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

RangeError: Maximum call stack size exceeded #31

Open
barvian opened this issue Dec 5, 2024 · 1 comment
Open

RangeError: Maximum call stack size exceeded #31

barvian opened this issue Dec 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@barvian
Copy link

barvian commented Dec 5, 2024

Repro

I was using the playground and somehow crashed it 😅 . Thanks so much for working on this by the way, it seems like it has the potential to dramatically improve the web 👋

@KermanX KermanX added the bug Something isn't working label Dec 5, 2024
@KermanX
Copy link
Owner

KermanX commented Dec 6, 2024

I just tried to fix this problem but found it harder than I thought. Here is the memo:

For ordinary function calls, the two following cases are considered recursion:

  1. One function instance is called while it's already in the call stack.
  2. One function instance is created while another instance of this function is in the call stack.

However, for the React component function, it's currently hard to detect whether two tags are equal/non-equal/both-possible, to apply rule 1 above.

If we change the two rules into "one jsx constructs itself", then we will get a poor tree-shaking result in the following case:

function wrapper(Comp) {
  return function Wrapped() {
    return <Comp />
  }
}

const C1 = wrapper(function () {
  return <div />
})
const C2 = wrapper(function () {
  return <C1 />
})

export function App() {
  return <C2 />
}

Because the jsx <Comp /> will be considered as recursion.

btw, thank you for your interest in this project~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants