The Unclear Impact

Re: javascript

@aral my first intuition would be that this always displays 1, because let count = 1 is on the top of the file, and it looks like it always gets executed when the page is rendered blobfoxglare

I’d expect a clearer separation between the initialization and the rendering, like

let count = 1;

export default function render() {
  return <div>{count++}</div>;
}

or maybe even (goodness forbid!)

let count = useState(1);

return <div>{count++}</div>;

(btw, won’t the code display 1 times even on the first request, because the condition count > 1 gets evaluated after the post-increment? granted, I’m not familiar with the order of side-effects in jsx interpolation expressions)

replies
1
announces
0
likes
1