Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
leksyib94516yI also think how it looks sucks when you have about 5-6 different data in states while using the new hooks
-
I will not refactor what is already there. I will however use it in newly created components or projects.
Sidenote: I am already living a classless life because in ReasonReact you only have functions and modules. And it compiles down to ES5 which is also without classes. -
leksyib94516y@finiteAutomaton oh cool! You won't get hit hard if react decides to remove classes. But I've never tried reasonReact. What perks do you get with reasonReact? (I know bundle size will be smaller since they're just funcions)
-
@leksyib
Okay, as I am not sure if you really know what I am talking about, a small Primer:
* ReasonReact is the glue library to write React in ReasonML which is a JS-developer friendly syntax for the OCaml language.
* ReasonML provides you with a 100% covered type system, better than flow and typescript (because soundness is no goal of typescript)
* It also has some smart features JS will probably get in decades, like pattern matching which is one of the things you did not know you needed before you used it. Also, it's immutable by default.
* ReasonReact brings also reducer functionality included to the table, (also Side-Effects) so in general you need many fewer dependencies.
* To import and use JS libraries and ReactJS components in ReasonML, you have a bunch of tools from the bucklescript project, generally the interoperability with JS is good.
That being said, it is an all different language to learn, and it is mainly functional, but imho it is worth it. -
leksyib94516y@finiteAutomaton sounds cool, thanks! I'll definitely check out reasonML in my free time
-
Root797676yThey look interesting!
I'm about a year behind in React news, so I'll have to start fresh, I fear. -
yangshun2146yI work at Facebook and we have been using it in our code base for a while.
General sentiment towards hooks are positive. There are many benefits of hooks which you can find on the React website.
However, the React team emphasizes that you would be better off not rewriting your whole app with hooks for these reasons:
1. It's still experimental, APIs may change in future
2. It takes effort to rewrite your app, and the marginal benefits are questionable. Hooks are great when writing new code because they are shorter but if you have already written code in classes, you have paid the cost and rewriting it wouldn't help much.
There's one reason to rewrite though - smaller bundle size because classes (which lifecycle method names can't be transpiled) are now gone from the bundle.
I would advise you to try it out but not commit too much to it. Wait for it to be more stable and for best practices around using hooks to emerge before rewriting your whole app in it. -
I think hooks are great, taking off a lot of boilerplate. Quite a shift in a way we’re gonna write React components.
-
leksyib94516y@maushax Yeah I read that, but I'm sure the maintainers are working hard to fix that!
-
leksyib94516y@dangerzone haha nope it's destructuring.
In es6, if there's an object = {a:1, b:2 }.
I can do
const { a, b } = obj
And use a and b as separate variables.
So that's how this works, you destructure the state's name and the function to change that specific state from useState. -
kjdion843086y@leksyib that's a long way of saying "a class".
So the reinvented wheel is called "destructuring". Gotcha. -
@maushax Yeah, you need to git gud at writing bindings if you want to make a serious project, because even if there are bindings they may already be outdated syntax, or only partially.
So it is sensible to create your own bindings but only for the features you actually use.
That is probably the biggest hurdle in learning Reason/Bucklescript.
Related Rants
React developers, What do you think about the new hooks api?
Will you refactor your codebases to use functional components or just stick with classes (even though the react community is moving towards removing classes completely)?
I think its awesome as it reduces the bundle sizes if you use function components though. I have been working on an awesome project for a while and I'm being tempted to refactor the whole codebase to use functions instead of classes. What do you think?
question
react