4,836 karma · joined February 6, 2010
You can use the various builtin hooks to do stuff that (in class-based React) previously required implementing methods (eg. componentDidUpdate). Using those methods works fine until you want to split out and reuse part of those methods in other components.
You can certainly try class composition: creating little classes that you call in each of the relevant lifecycle methods. However this adds a lot of boilerplate to components which use the composed objects (as is common with class composition). It's also awkward to share the setState API with these composed classes.
The Custom Hooks approach[1] with React Hooks just makes it really easy to use state and lifecycle functionality when extracting common behaviour to can be shared between multiple components.
React has tried to address this composition issue several times in the past, and I think hooks are the nicest yet:
React's old 'Mixins' feature got a lot of the way there, but still didn't compose perfectly. For example, you had to avoid method and state key name collisions between mixins.
Creating a 'Higher Order Component' is another approach, which is less verbose than class composition, but makes your component tree deeper, and can also be annoying to statically type.
The community also came up with 'Render Props' to address much the same issue.
And of course, you can always just continue to use classes if you aren't experiencing any of these pain points.
Hooks just compose quite nicely in cases where none of these other approaches do.
There are many other tutorials on the web but the official one has had a lot of work put in to making it seamless and letting you get a feel for what it's like to work with React without throwing too many tangential ideas at you.
https://github.com/jsdf/reason-react-hacker-news (rather unimaginatively, a hacker news app)
https://github.com/jsdf/lisp.re (native, the start of a lisp in Reason)
In practice this probably means adding some logging of how long requests take and graphing it (say, 95th percentile request time) from time to time to spot pathological queries. Even better if you can automate it. I think this is stuff that everyone should be doing (after a certain stage), regardless of whether you are using GraphQL or a bespoke JSON API.
In the 'join in SQL' case you could identify particular cases which are doing sequential queries and implement a different loader which just does one. It's not automatic but perhaps in most cases it's not necessary to do this step anyway. In the worst case you're back to doing as much work as you would for a bespoke API endpoint, but that's not the typical case. How much of a problem this ends up being in practice very much depends on the type of app you're building and how you intend to scale it.
Large chunks of messenger.com are written in Reason. I'm pretty sure that qualifies as a 'web app'.
The language/compiler itself is installed as an npm package(!). The only other things to install are the CLI tools (again, just an 'npm install' away) and optionally a plugin for your editor.
Some things I feel are an improvement over Javascript + Flow or Typescript are:
- immutable data structures built into the language (and more conventionally used)
- real pattern matching on types, 'variant' types (like enums in Rust)
- better dead code elimination (helps to keep browser payload size down)
- you can use expressions everywhere (allowing more flexible code style than Javascript)
- currying/partial evaluation
- under the hood it's really just OCaml, which has benefitted from many years of development and improvement
Tech overview: http://fabiensanglard.net/anotherWorld_code_review/
The essential part of Redux is only 44 lines of simple code [1]. You can understand everything that it is doing. That is simple. It doesn't mean that it's going to be a great experience to work with (you might want to add some abstraction on top to make it also 'easy'), but it is definitely simple.
[0]: https://www.infoq.com/presentations/Simple-Made-Easy
[1]: https://gist.github.com/gaearon/ffd88b0e4f00b22c3159#file-sl...
The simplest option is just to read and write a blob of JSON using the AsyncStorage API: https://facebook.github.io/react-native/docs/asyncstorage.ht...
Another option you could try is Realm, which is commercial but has a free tier (even for commercial apps) and has a pretty simple API: https://news.realm.io/news/introducing-realm-react-native/
Another is the SQLite module which comes with Expo:
Docs: https://docs.expo.io/versions/v16.0.0/sdk/sqlite.html Example: https://github.com/expo/sqlite-example/blob/master/main.js
Having the DOM as your canonical representation of state is only suitable for apps with limited state IMO, because your state effectively has to be turned into text (CSS class names and element attributes) whenever it is mutated, which becomes a liability as the complexity of your app state grows.
I realise that doesn't answer your question (which seems to be 'please justify React Native having a lot of open Github issues and being seemingly less stable than React') but it seems a bit misleading to conflate the two projects, and to expect the same amount of stability from each. React is a UI library. React Native comprises of a UI library, a JS <-> native binding system with wrappers for native APIs, a build system, and an implementation of CSS-like layout for native views. They are not really comparable.
The article shows snippets from the Redux and React Router docs, implying they are realistic examples of the way that typical React code should look, however, they are clearly snippets which are trying to show the entirety of an API on one screen. If your code is just a bunch of snippets copy-pasted from docs without much thought given to the structure of your code, your choice of UI library isn't the problem.
On React Router, React Router is not React. You don't need to use React Router. There are plenty of stable pure JS routing libraries, which don't release new versions often (or ever, because they are 'done'). Nothing about React requires you to use a React-related routing library.
The author found Redux and MobX too complex for their use case. However, Redux and MobX are not required to use React (there seems to be a theme here), and probably not useful if you don't have a big single page app with a lot of client side state. Implying they are intrinsic aspects of using React is wrong.
The bits at the end:
you will need to import in your scripts react-dom and react without never using the last one instance for some wild reason known only by the React team
The react and react-dom packages are being split so react-native doesn't have to pull in dependencies which are only used on the web. Not that different to Rails splitting up into a bunch of gems.
you can render functional components just by using js functions but you will need to wrap all your markup always in a wrapper tag to properly allow the Virtual DOM creation
This was an architectural limitation which is going away in the next major version.
its apparent simplicity is hidden behind a whole toolchain you need to configure before you can even writing 1 line of code
Why complain about this but refuse to use create-react-app? It literally solves this problem.
I started my app with React 15.5.0 knowing that my code is deprecate before even starting because facebook has just announced that for the next major release they are planning a complete rewrite of the framework and this means that they will likely nuke the current source because it can be no longer maintained.
This is FUD. The team has said that the next version of React will have some small breaking changes, but the API will remain almost completely the same. Not sure what they mean by 'nuke the current source' though.
The analogy you make to solar ignores that the failure modes of nuclear are much worse than solar.
The Macintosh ROM is up to the website (e.g. archive.org) to provide, along with the disk images.