Duplicates
Latest version
Current behavior 😯
Setting a signal inside ResizeObserver API causes screen to flash and blank null errors in console.
Expected behavior 🤔
It behaves fine in normal SolidJS (both dev and build)
It behaves fine in SolidStart (just the build)
I expect it to behave fine in SolidStart dev mode
Steps to reproduce 🕹
- Create a new SolidStart project
- Add this code to a page
import { createSignal, Index, onMount } from "solid-js";
const getSquaresPerRow = (containerWidth: number, squareMinWidth: number, gap: number) => {
return Math.floor((containerWidth + gap) / (squareMinWidth + gap))
}
export default function Home() {
const [squares] = createSignal(Array(20).fill(0))
const [test, setTest] = createSignal(0)
let containerRef!: HTMLDivElement
const onContainerResize = (entries: ResizeObserverEntry[]) => {
const newSquaresPerRow = getSquaresPerRow(entries[0].contentRect.width, 260, 2)
setTest(newSquaresPerRow)
}
onMount(() => {
new ResizeObserver(onContainerResize).observe(containerRef)
})
return (
<div ref={containerRef}>
<div style={{ 'display': 'grid', 'gap': '2px', 'grid-template-columns': `repeat(${test()}, 1fr)`}}>
<Index each={squares()}>{square => <div style={{ 'background-color': 'gray', 'aspect-ratio': 1 }}></div>}</Index>
</div>
</div>
);
}
- Open the console, should have errored by then, in case not resize the viewport.
Context 🔦
I am trying to use ResizeObserver in dev without getting errors

Your environment 🌎
Chrome on Fedora Linux
used Bun
Duplicates
Latest version
Current behavior 😯
Setting a signal inside ResizeObserver API causes screen to flash and blank null errors in console.
Expected behavior 🤔
It behaves fine in normal SolidJS (both dev and build)
It behaves fine in SolidStart (just the build)
I expect it to behave fine in SolidStart dev mode
Steps to reproduce 🕹
Context 🔦
I am trying to use ResizeObserver in dev without getting errors

Your environment 🌎