QwikDev / qwik

Instant-loading web apps, without effort
https://qwik.dev
MIT License
20.71k stars 1.29k forks source link

[🐞] Math.round is not serializing into q:func #4769

Open mhevery opened 1 year ago

mhevery commented 1 year ago

Which component is affected?

Qwik Optimizer (rust)

Describe the bug

import { component$, useSignal } from '@builder.io/qwik';

export default component$(() => {
  const count = useSignal(123);
  return (
    <>
      Count: {Math.round(count.value + 1)}
      <button onClick$={() => (count.value += 0.5)}>+1</button>
    </>
  );
});

The above should serialize into:

<script q:func="qwik/json">
  document.currentScript.qFuncs=[
    (p0,)=>Math.round(p0.value)
  ]
</script>

But it does not. The result is that the component is being downloaded and re-rendered using the JSX path rather than the signal-dom path.

Reproduction

https://stackblitz.com/edit/qwik-starter-v96ske?file=src%2Froutes%2Findex.tsx

Steps to reproduce

No response

System Info

n/a

Additional Information

No response

stackblitz[bot] commented 1 year ago

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

gioboa commented 3 months ago

@Varixo @wmertens is this case addressed with Qwik v2?

Varixo commented 3 months ago

@Varixo @wmertens is this case addressed with Qwik v2?

I don't think so :/

JerryWu1234 commented 2 months ago

Maybe I can try this one

JerryWu1234 commented 2 months ago

I dug into this problem and discovered this bug in Rust. I struggle with Rust, so it takes me a long time.