Unexpected content loss
#2369
-
import { render } from "solid-js/web";
import { createSignal, Show,createEffect } from "solid-js";
function App() {
const [x,setX] = createSignal(false);
const [y,setY] = createSignal(true);
createEffect(()=>{
console.log("sv",x()||y())
})
return (
<>
<Show
when={x()||y()}
fallback={
<></>
}
>
<p>{x()} {y} is greater than 10</p>
<input/>
</Show>
<button onClick={()=>{
setX(!x())
setY(!y())
}}>toggle</button>
</>
);
}
render(() => <App />, document.getElementById("app")); If I enter anything in the input and click the button twice, the content will be lost, but this shouldn't be the case. |
Beta Was this translation helpful? Give feedback.
Answered by
atk
Nov 22, 2024
Replies: 1 comment
-
I believe this is because the setter calls are not batched. If you wrap them in |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
wy2010344
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I believe this is because the setter calls are not batched. If you wrap them in
batch(() => ...)
, the issue should not occur anymore.