by eqvinox · 2y ago · 0 comments
[ed.: looks like this was an encoding problem, cf. thread below. I'm still a little concerned about correctness though.]
// ORIGINAL:
j.useEffect(() => {
function r() {
n({ height: window.innerHeight, width: window.innerWidth });
}
if (typeof window < "u") return n({ height: window.innerHeight, width: window.innerWidth }), window.addEventListener("resize", r), () => window.removeEventListener("resize", r);
}, []),
// UNMINIFIED:
useEffect(() => {
const handleResize = () => {
setSize({ height: window.innerHeight, width: window.innerWidth });
};
// Initial size setting
handleResize();
window.addEventListener('resize', handleResize);
return () => {
window.removeEventListener('resize', handleResize);
};
}, []);
Note that the original code doesn't call `handleResize` immediately, but have its contents inlined instead. (Probably the minifier did the actual inlining.) The only real difference here is a missing `if (typeof window < "u")` condition.Discrediting the entire output because a few missing characters would be very pedantic.
Otherwise, the output is identical as far as I can tell by looking at it.
[0] https://en.wikipedia.org/wiki/Windows-1252#Character_set
However, I don't think I miscopied the original code.
https://reactive.network/assets/index-8b4ef4ac.js
If you look for `oahkbdpqwmZO0QLCJUYXzcvunxrjft` in the output, you should see that those characters appear exactly like that. Maybe an issue with encoding of the script file?
I would guess if he just told it to rename the variables and method first, it would have been closer to the original.