The CGI example is straight copy/pasted from the official Perl guide, November 2018. https://www.perl.com/article/perl-and-cgi/
> Warning you probably don’t want to use CGI for modern web development, see Why Not to Use CGI.
The CGI example is straight copy/pasted from the official Perl guide, November 2018. https://www.perl.com/article/perl-and-cgi/
> Warning you probably don’t want to use CGI for modern web development, see Why Not to Use CGI.
Ref's are basically a 1 to 1 replacement for instance fields for mutable data (that doesn't cause rerenders).
https://reactjs.org/docs/hooks-reference.html#useref
There's always need for escape hatches and maybe I'm missing your use case, but in the context of a discussion about how hooks are more complicated than classes, what were you doing before with refs to solve your "re-render" on change scenario?
Your example was likely contrived, but modifying innerHTML should be replaced by putting whatever in state and simply rendering it. And use state for dependencies where you want to re-run on change. Refs are just another way to keep state but not have it affect render cycle.
If you're not aware of that, it is very tempting to use `useRef`, which is what I have often seen. Before hooks, we did not have the temptingly-named footgun `useRef` for this scenario (although we did have other footguns for other scenarios, and overall I love hooks).
This is simply a matter of reading the docs (or making the mistake until you learn). Not an inherently more complex characteristic than, say, Class component lifecycle methods, which also required understanding their rules and reading the docs.
Once you know refs updates won't re-render, you won't make this mistake.
I don't understand why "a thing you need to learn then you're good" is somehow inherently more complicated than ... other apis that you need to also learn.
> but most people think of refs as...
This sounds like Dan Abramov's comment that some of the struggles with hooks is from people who have experience with react without hooks, vs people coming new to the whole thing. So maybe it's about relaxing pre-conceived notions until experience takes over.
Also that the fix is "instead of using this one kind ref, use another kind of ref and put it in state"... I don't know, like I said I'm not sure if there is a better solution, but it still feels kind of unintuitive and complicated.
Now that I'm thinking about it... what is the reason that DOM refs and other refs need to be handled by the same concept? Every time I make a DOM ref, I'm doing something with it in a hook like useEffect. Why make me jump through hoops to re-run the hook if the DOM ref changes?
(I recognize there are probably good answers to those questions, the React folks are great, I just don't know the answers! Is it just to avoid introducing one more "type of thing", and instead making refs and DOM refs the same "thing"?)
On this particular point, the reasoning is that refs are meant for values that don't need to trigger a rerender[1] -- an escape hatch, rather than something you reach for by default.
In that sandbox, you can accomplish what you mean to accomplish by using state rather than a ref.
[1] https://github.com/facebook/react/issues/14387#issuecomment-...
I'm not sure if there is a less confusing way of doing it, but it's damn confusing.
How do you prevent vote selling and coercion?
For instance, several versions of Firefox had a serious bug in shared workers, which appeared intermittently when users opened your site in multiple tabs https://stackoverflow.com/questions/51092596/feature-detecti... - I had to use the user agent to work around this.
If we could detect pancreatic cancer early, for example, would could go from a 7% survival to 90% rate.
Early detection would still be valuable for other reasons, though.
Is that actually allowed by the GPL? I thought it was more like the "Ship of Theseus" - that even if you eventually replace all the original GPL code, the entire work remains GPLed. https://softwareengineering.stackexchange.com/questions/2603...