Skip to content

Commit 7ac7a9e

Browse files
authored
Website: Blog post about release of reason-react-native & bs-react-native-jsx3-compat (#537)
* Website: Blog post about release of reason-react-native & bs-react-native-jsx3-compat * Update 2019-06-04-hello-reason-react-native.md * Update 2019-06-04-hello-reason-react-native.md
1 parent 958cd4e commit 7ac7a9e

1 file changed

Lines changed: 132 additions & 0 deletions

File tree

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
id: 2019-06-04-hello-reason-react-native
3+
title: Hello Reason React Native
4+
---
5+
6+
Today is a big day for the ReasonML community as we are releasing the fruits of
7+
a long effort started about 3 months ago.
8+
9+
As more and more people were starting to use ReasonML on production apps using
10+
React Native, we wanted to make the BuckleScript bindings for React Native,
11+
known has `bs-react-native`, more accessible. This would have involved several
12+
breaking changes in order to simplify some APIs that have been designed with a
13+
high level of security in mind, but at some costs. The cost of being harder to
14+
start with (for newcomers to ReasonML) as well as the cost in terms of code size
15+
and performance.
16+
17+
While some of us were thinking about some simplifications, some others, involved
18+
in Reason React incoming changes, directly started a new approach for this
19+
bindings, following
20+
[the zero-cost approach offered by reason-react 0.7.0](https://reasonml.github.io/reason-react/blog/2019/04/10/react-hooks).
21+
22+
[CCA](https://www.cca.io) started this effort on what is now know as the new
23+
`reason-react-native` bindings, that eliminates a huge part of the additional
24+
JavaScript code produced by the bindings.
25+
26+
## Zero-cost
27+
28+
By zero-cost, we means zero additional cost. The JavaScript code BuckleScript
29+
produces using this bindings will most of the time directly hit React Native
30+
JavaScript code without creating an unnecessary abstraction above it 🙌.
31+
32+
Here are some random examples:
33+
34+
- [`bs-react-native` `View`](https://github.com/reasonml-community/bs-react-native/blob/958cd4e3a5ffa303304a0b2404cd53b5f49e649f/bs-react-native/src/components/ViewProps.bs.js)
35+
vs
36+
[`reason-react-native` `View`](https://github.com/reasonml-community/bs-react-native/blob/958cd4e3a5ffa303304a0b2404cd53b5f49e649f/reason-react-native/src/components/View.bs.js)
37+
- [`bs-react-native` `Style`](https://github.com/reasonml-community/bs-react-native/blob/958cd4e3a5ffa303304a0b2404cd53b5f49e649f/bs-react-native/src/style.bs.js)
38+
vs
39+
[`reason-react-native` `Style`](https://github.com/reasonml-community/bs-react-native/blob/958cd4e3a5ffa303304a0b2404cd53b5f49e649f/reason-react-native/src/apis/Style.bs.js)
40+
- [`bs-react-native` `Platform`](https://github.com/reasonml-community/bs-react-native/blob/958cd4e3a5ffa303304a0b2404cd53b5f49e649f/bs-react-native/src/platform.bs.js)
41+
vs
42+
[`reason-react-native` `Platform`](https://github.com/reasonml-community/bs-react-native/blob/958cd4e3a5ffa303304a0b2404cd53b5f49e649f/reason-react-native/src/apis/Platform.bs.js)
43+
44+
Some modules are even empty or with some minor `require()` that can be
45+
themselves almost empty and easily removed by some JavaScript bundlers.
46+
47+
How cool is that?
48+
49+
## But why`reason-react-native` ?
50+
51+
`bs-react-native` already had multiple breaking changes in the past and we
52+
didn't really want to offer a poor experience by creating a new release with
53+
tons of changes that won't be easy to codemod (or would require much more work
54+
from us).
55+
56+
On top of that, `reason-react` latest release already added an important
57+
breaking change with
58+
[JSX 3](https://reasonml.github.io/reason-react/docs/en/jsx).
59+
60+
That's why we had this idea about offering an easy and smooth transition by
61+
offering 2 packages to say goodbye to `bs-react-native` without pain.
62+
63+
- `bs-react-native-jsx3-compat`
64+
- `reason-react-native`
65+
66+
## Wait, what is `bs-react-native-jsx3-compat` ?
67+
68+
`bs-react-native` is using JSX 2 so in order to use it with JSX 3 we would have
69+
to create an additional layer on top of the current bindings to offer both JSX 2
70+
and 3 bindings. And since we wanted to do away with some current APIs of
71+
`bs-react-native` we started to think about a new approach.
72+
73+
We knew that we wanted to:
74+
75+
- offer to `bs-react-native` users a migration plan, so they can start very
76+
easily to use JSX 3 and new `reason-react` (so they can use hooks),
77+
- offer new `reason-react-native` bindings, more accessible and with a zero cost
78+
approach.
79+
- offer a smooth transition between these two packages so people can slowly
80+
upgrade their codebase without having to make an insane PR that switches from
81+
one to the other.
82+
83+
We don't want your co-workers to hate you with a PR that comes directly from
84+
hell 😅.
85+
86+
That's where we thought about offering `bs-react-native-jsx3-compat`. It's a
87+
package that has the same APIs `bs-react-native` has but that uses
88+
`reason-react-native` under the hood.
89+
90+
**This means you will have to make a migration from JSX 2 to 3**. That's the
91+
only thing you will have to do, then with a single change from `bs-react-native`
92+
with `bs-react-native-jsx3-compat` in your `bs-dependencies` you will be ready
93+
to use hooks and directly benefit of (almost) zero-cost bindings!
94+
95+
And since we care about you and don't want you to upgrade from JSX 2 to 3 by
96+
hand, we got you covered with a script made with love to help you with that.
97+
98+
[You will find all the required instructions to migrate from `bs-react-native` to `bs-react-native-jsx3-compat` in our documentation](/reason-react-native/en/docs/migration/jsx3/).
99+
100+
## tl;dr
101+
102+
- `bs-react-native` has now entered a frozen state and won't receive any upgrade
103+
- `bs-react-native-jsx3-compat` allows you to use existing code based on
104+
`bs-react-native` with `reason-react` 0.7.0 and JSX 3
105+
- `reason-react-native` package contains the new bindings for React Native, that
106+
offers more accessible APIs and that is almost zero-cost
107+
- [We offer you an easy and smooth migration plan so you can start using `reason-react-native` and slowly say bye to `bs-react-native`](/reason-react-native/en/docs/migration/jsx3/).
108+
109+
## Thanks
110+
111+
This required effort has been keeping us busy for weeks and wouldn't have been
112+
possible without the following people:
113+
114+
- CCA team and especially @cknitt for leading us to the right direction for the
115+
new zero-cost bindings and all the contributions that come with this move
116+
- @sgny for all his contributions to the new bindings
117+
- @MoOx for leading the effort, the compat layer and the new website you are
118+
seeing here
119+
- @bloodyowl for his magical
120+
[reason-react-compat](https://github.com/bloodyowl/reason-react-compat) layer
121+
and
122+
[the alternate JSX 3 upgrade path](https://bloodyowl.github.io/blog/2019-04-19-an-alternative-migration-path-for-reason-react/)
123+
that goes with it
124+
- all the people that helped us on Discord and GitHub in various code reviews
125+
and improvements like the react native template (thanks @dawee)
126+
127+
## What's next?
128+
129+
Now that `reason-react-native` is ready to be used and that our migration plan
130+
is usable, we will probably be focused on documentation as lots of APIs and
131+
Components need to be documented. We really want to offer the best developer
132+
experience possible and that's definitely part of it.

0 commit comments

Comments
 (0)