News for hackers. Stuff that matters.
Re:Angular v8.0 by jaquers on Wednesday May 29, 2019 @09:48AM (#20040091)
https://reactjs.org/docs/hooks-intro.html

edit: Lol apparently two React devs ears were burning at the same time.

Re:Angular v8.0 by merb on Wednesday May 29, 2019 @09:58AM (#20040223)
well 16.8 (which basically was the latest version)

also btw: https://reactjs.org/docs/hooks-faq.html#do-i-need-to-rewrite...

and I still have no idea how I only do stuff on the client in a SSR environment (stuff that i did in componentDidMount)

Re:Angular v8.0 by allover on Wednesday May 29, 2019 @11:10AM (#20041082)
> and I still have no idea how I only do stuff on the client in a SSR environment (stuff that i did in componentDidMount)

The 'useEffect' hook - it won't be executed if you use e.g. ReactDOMServer.renderToString() for SSR

    useEffect(() => {
      console.log('Client side only');
    }, []);
Codesandbox: https://codesandbox.io/s/peaceful-dew-nvw83
Re:Angular v8.0 by azimuth11 on Wednesday May 29, 2019 @02:25PM (#20043622)
While you wouldn't want to leave "console.log" in your code in production, you can use them in function components just like a classes' render methods.

A better example (from the video "React Today and Tomorrow and 90% Cleaner React With Hooks" from October[1]) is something along the lines of updating document.title = `${some} Page` or possibly calling an API.

[1]: https://www.youtube.com/watch?v=dpw9EHDh2bM

Re:Angular v8.0 by allover on Thursday May 30, 2019 @08:15AM (#20050377)
The console.log was only there to illustrate that the code in useEffect's callback is only being run on the client-side (see the codesandbox I linked to).

I think it's clear from the parent I was responding to that they have better use-cases in mind :)

Re:Angular v8.0 by jaquers on Wednesday May 29, 2019 @12:24PM (#20042142)
Btw, totally agree about classes. I still like the 'look' of them for stateful components.