I don't get it. I thought the main appeal of functions were that they were stateless so you had immutability. We already have classes if we want state, so why is this an improvement? Functions have slightly less overhead maybe? But then why didn't the React team just work on making classes have less overhead? It seems sort of "extra".
With React 16.8, React Hooks are available in a stable release
11–20 of 181 posts
Re: With React 16.8, React Hooks are available in a stable release
#12I don't get it. I thought the main appeal of functions were that they were stateless so you had immutability. We already have classes if we want state, so why is this an improvement? Functions have slightly less overhead maybe? But then why didn't the React team just work on making classes have less overhead? It seems sort of "extra".
Re: With React 16.8, React Hooks are available in a stable release
#13I don't get it. I thought the main appeal of functions were that they were stateless so you had immutability. We already have classes if we want state, so why is this an improvement? Functions have slightly less overhead maybe? But then why didn't the React team just work on making classes have less overhead? It seems sort of "extra".
var foo = 1;
var bar = x => x++;
module.exports = function baz() { return bar(foo) }
I find this much more simple then classes. I even consider it an anti-pattern to make a class for something this simple.Re: With React 16.8, React Hooks are available in a stable release
#14Earlier quoted context omitted.
I've been working with hooks for quite a while now; its main benefit is composability - before hooks up you rely on Higher order components (HOCs, HOFs but in component rendering) to provide composability of component behaviour - this is messy, very messy, and not performant. By using hooks the logic tidies up massively (so working on it becomes a lot quicker) and several hard to diagnose performance bottlenecks disa…
Can you please give some example of behaviour that you share across components that couldn't be factored out into a function?
Re: With React 16.8, React Hooks are available in a stable release
#15Earlier quoted context omitted.
I've been working with hooks for quite a while now; its main benefit is composability - before hooks up you rely on Higher order components (HOCs, HOFs but in component rendering) to provide composability of component behaviour - this is messy, very messy, and not performant. By using hooks the logic tidies up massively (so working on it becomes a lot quicker) and several hard to diagnose performance bottlenecks disa…
Can you please give some example of behaviour that you share across components that couldn't be factored out into a function?
Re: With React 16.8, React Hooks are available in a stable release
#16Never a boring day being a frontend developer. Looking forward to add hooks to my React project. The next frontier would probably be functional strongly typed languages, like Reason or some variation on Elm?
A variation on Elm? Why not just Elm?
Re: With React 16.8, React Hooks are available in a stable release
#17The crowd goes mild.
Re: With React 16.8, React Hooks are available in a stable release
#18I don't get it. I thought the main appeal of functions were that they were stateless so you had immutability. We already have classes if we want state, so why is this an improvement? Functions have slightly less overhead maybe? But then why didn't the React team just work on making classes have less overhead? It seems sort of "extra".
Re: With React 16.8, React Hooks are available in a stable release
#19I don't get it. I thought the main appeal of functions were that they were stateless so you had immutability. We already have classes if we want state, so why is this an improvement? Functions have slightly less overhead maybe? But then why didn't the React team just work on making classes have less overhead? It seems sort of "extra".
Re: With React 16.8, React Hooks are available in a stable release
#20I don't get it. I thought the main appeal of functions were that they were stateless so you had immutability. We already have classes if we want state, so why is this an improvement? Functions have slightly less overhead maybe? But then why didn't the React team just work on making classes have less overhead? It seems sort of "extra".
Not specific to React, but with CommonJS modules you can use module scope instead of global scope to get private methods and variables, which the function can access via the closure. var foo = 1; var bar = x => x++; module.exports = function baz() { return bar(foo) } I find this much more simple then classes. I even consider it an anti-pattern to make a class for something this simple.