Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[article] - Why's React Native so promising? #1

Merged
merged 3 commits into from
Feb 27, 2018

Conversation

carvallegro
Copy link
Contributor

No description provided.


Now this article is not an introduction to React. This is merely a gathering of the thoughts I had and discoveries I made during this project. React Native is very good and hopefully this article will bring more people to use it and help bring the framework to maturation.

## React is **not** a framework. React Native is one.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start titles at level 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚵


The most known Higher Order Function is the Redux `connect` function that allows you to bind the props of a "dumb" Component to the Redux Store. Here's a quick reminder of the function's profile:

```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the language on code snippets: javascript

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚵


I find that in the frontend world, lots of people compare Angular and React as if they were equals. But there's an important distinction, React is only a rendering library. Whereas Angular bundles a lot of features together, you will need to use a lot of different libraries to have equivalent functionality with React. Redux being the most popular state management library to use with React you'll ship them together, making the stack a kind of framework. I think it is important to know the difference and understand that you cannot really compare them.

Enter React Native. React Native looks a lot like React: roughly the same syntax, classes, JSX, state, props...but React Native is a framework, which means you have more features than just rendering in React Native. And that's simply because React Native needs to interact with the mobile it's running on. To do that, the Facebook team created a bunch of APIs to interact with the camera, the keyboard, the vibrations...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"...but" -> "... but"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚵


I find that in the frontend world, lots of people compare Angular and React as if they were equals. But there's an important distinction, React is only a rendering library. Whereas Angular bundles a lot of features together, you will need to use a lot of different libraries to have equivalent functionality with React. Redux being the most popular state management library to use with React you'll ship them together, making the stack a kind of framework. I think it is important to know the difference and understand that you cannot really compare them.

Enter React Native. React Native looks a lot like React: roughly the same syntax, classes, JSX, state, props...but React Native is a framework, which means you have more features than just rendering in React Native. And that's simply because React Native needs to interact with the mobile it's running on. To do that, the Facebook team created a bunch of APIs to interact with the camera, the keyboard, the vibrations...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a link to React Native's website the first time the framework is mentioned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚵


## React Native is a lot like React.

As mentioned previously, in terms of "developer look and feel" React Native and react are very similar. You use classes, ES6, states and the like, with a few notable differences:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"react" -> "React"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚵


### Redux works with React Native

Not much to say here except that Redux, the React developers' favourite state management library, is also working with React Native with absolutely no difference in the way you'll dev.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"is also working" -> "also works" (?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚵


### You can do stateless components and use HOC in React Native

Stateless components and High Order Components (HOC) are, for me, the revelation of the year. It allows a greater flexibility in your component creation and is way lighter than the use of React Component class inheritance. Coming from a backend world, I started React by using classes because that's what I'm used to (Java, guys, Java) and I didn't knew much about functional programming. It took a senior front-end dev to open my eyes on this wonder.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"what I'm used to" -> "what I'm used to using"
"Java, guys, Java" -> not sure what you mean!
"I didn't knew" -> "I didn't know"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the sentence a bit to send the message differently

And, guess what, the best way to manage state in a stateless world is to use a Higher Order Component! Using the excellent [recompose](https://github.com/acdlite/recompose) library that provides a lot of React specific Higher Order Components, you can easily create reusable snippets for a lot of use cases.

Here's an example of a small Menu component:
<script src="https://gist.github.com/carvallegro/6167b34b0cdf9b6b19cb4358320d5856.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the script to a normal link?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this is to embed my gist into the page (avoid a huge bunk of code as it has scrolling and all)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


#### Further reading

I’m not here to talk about those but know they allow a greater flexibility around the way you compose your components and you can use them in React Native. This was only a short introduction of what HOCs are. If you want more information about it, here are just a few good article about it:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"but know" -> reformulate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformulated


First of all, no, it is not a CSS in JS kind of library. It spits out CSS classes (with obfuscated class names). The main feature of this library is that it uses the power of ES6's string templates; you can use the component's props and state directly in its style and let style-component do its magic.

Because the style-components dev team is awesome,~~they made it compatible with React Native with only one simple change~~ Because they're **really awesome** they improved the use for React Native in their 3rd major release by making it seamless. A single import will be compatible with React and React Native.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing "." before the second "Because"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lower cased the B


## Dev environment (HMR…).

My recommendation to avoid any hassle with the dev environment is to use the create-react-native-app package. It will generate a basic RN app with a default configuration; which is more than enough for most cases. If necessary, you can drop create-react-native-app at any time by running `npm run eject` but be careful, there's no going back! Keep that option away unless you really need to include your own native code.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create-react-native-app package -> add link?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚵


## Who uses/contributes to React Native?

As of today, [heaps of companies](http://facebook.github.io/react-native/showcase.html) are using React Native in production. Amongst them you can find Tesla, Instagram, Facebook, AirBNB, Skype, Wix...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"heaps" -> "lots"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same same

@aseigneurin aseigneurin merged commit 6023b60 into ippontech:master Feb 27, 2018
aseigneurin pushed a commit that referenced this pull request Aug 1, 2018
aseigneurin added a commit that referenced this pull request Aug 1, 2018
* kafka tutorial #1

* updated tags
David-Elizondo pushed a commit to David-Elizondo/blog-usa that referenced this pull request Jul 21, 2023
David-Elizondo pushed a commit to David-Elizondo/blog-usa that referenced this pull request Jul 21, 2023
NShaw6 added a commit to NShaw6/blog-usa that referenced this pull request Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants