Is it possible to use React.js in React-Native? - reactjs

Using React-Native, I'll make Native app. But I don't know anything about it.
So, I am going to buy some books about React-Native.
If It is possible to use React.js in React-Native, then I will buy the book about React.js .
Is it possible?
ps. Do you know some links or website about React-Native? Please Share!

React-Native uses the same syntax as React.js. You have to use React in order to use RN, but the functions, methods and components are not the same. (There is no , no documentElement or anything else).
You should take a look at the Fabebook documentation for React & RN:
https://facebook.github.io/react-native/
https://facebook.github.io/react/

Related

sharing code between react js and react native expo

I want trying to figure out is it possible to share code between reactjs and react native expo. I want to build an app for production. If yes then what should be the structure of project. I tried to do alot of google search but could find any article or tutorial on using react native expo with reactjs. Any one please help me to figure this out.
Probably the easiest way is to just write React code in Expo and then use Expo web to make the website.
It is possible to share code between a React DOM project and an Expo project but there are some caveats and gotchas. There are a bunch of blog posts out there that outline some techniques to do this. Here is one example: https://codeburst.io/reusing-code-between-react-js-and-react-native-effectively-12bb4fbf7a70

Is Redux the same for React and React native?

I am currently studying RN by myself, without prior knowledge in React. A lot of things seem to exist in both such as Redux and hooks. Many of the resources I find refer to React in the title (e.g "Redux Crash Course With React").
My question is: where does the line cross between React and React Native? Would I be fine studyig form these resources that refer to React, or would that just confuse me?
I'm trying to understand a go to approach to understand which resource I'd be fine with and which would be irrelevant.
React Native contains React library to use it as front-end library.
Most of usages of React are the same for React-Native. And it is same for Redux too.
React-Native must have other libraries to build applications that can run on both of Android and iOS.
Also it has middleware libraries that allow us to use most of native libraries' functionalities. As an example you can check Alert directory out. It is used for to show native Android alert dialogs.
Good luck..
Both react and react native use javascript to create the user interface we need but the difference is in the rendering, style and bundling and you should know that react native is a framework itself but react.js is a library. the main difference:
---React-Native doesn’t use HTML to render the app, but provides alternative components that work in a similar way. Those React-Native components map the actual real native iOS or Android UI components that get rendered on the app.
---With React-Native, you’ll have to learn a completely new way to animate the different components of your app with Javascript.
--- navigating between pages are totally different!!!
so we conclude that it's better to study references based on RN not react.js . but some functionalities such as redux or hooks or a lot of it's components are exactly the same and you can study react.js references for them. only the 3 differents that i said above are important.

react-navigation for react-native-web?

Need to reuse the react-navigation code from mobile to react-native-web. But I could not able to get it work in web.
Should we need to use react-router for web separately?
How can we configure navigation commonly for both platform?
I would love to see an example of this! It would be super helpful. Thank you!!
The above answers are quite old now I'd say as react-navigation has upgraded itself quite a bit since then.
react-navigation v4 has intensive support for react native web, now you don't need to maintain two separate navigation objects for web and app.
This blog explains it in detail. https://codersera.com/blog/how-to-do-navigation-in-react-native-web-in-2020/
Maybe you can check this implementation
Using React Native, React Native Web and React Navigation in a single project

React + React Native starter kit

I am going to develop a web + mobile application using React and React Native. I'd like to share as much code as possible between React and React Native. I was looking for some starter kits, but found only este. However, for me, it seems to be an overkill as it has too many dependencies (also I wasn't able to make it work for Android - when I fix some error, I run into another one).
I'd like to have just React + React Native + Redux + web bundling etc. Are there any other alternatives? Or at least very simple example apps that I could use?
Did you check the awesome React-native list ?
As I said in this thread, as long as you follow the component / container pattern with Redux; you are able to reuse a lot of code.
The pattern encourages you to separate every presentational code into the comopnent. The container holds all the logic.
Then when you want to reuse the code, you just have to rewrite the component.
Here is a great explanation on how to implement it.
Also, you may want to check React-native-web. It allows you to code in react-native for the .... browser.
Update: I now know why there aren't almost any starter kits that would combine React + React Native. The reason is that it is not a good idea to combine web React and React Native. Just create two separate apps, you'll save yourself a lot of headaches. For those still interested in combining the two platforms, have a look at React Native for Web instead.
So in the end, I've created my own started kit. You can find it here: https://github.com/gina-system/react-starter
why do not you check out https://github.com/teallabs/react-native-init
pretty amazing react-native starter kit with codepush, google signin, sentry, react-navigations and all setup steps.

Share Component/Logic between React and React-Native

Im trying to create an application targettng both web and mobile. The idea is to create react components that differ on how they render but share the logic.
React v.014 blog post stated "we’re splitting the main react package into two: react and react-dom. This paves the way to writing components that can be shared between the web version of React and React Native.
The react package contains React.createElement, .createClass, .Component, .PropTypes, .Children, and the other helpers related to elements and component classes. We think of these as the isomorphic or universal helpers that you need to build components."
I've found a great example (http://blog.benoitvallon.com/projects/a-mobile-desktop-and-website-app-with-the-same-code/) that uses the same concept and accomplished the result (react-native 0.13.6 and react 0.14.2).
In this code, you will see nothing special just a smart idea on how to extend react-native naming conventions system to include a web version. The minute I upgrade to latest react-native, it complaints about any component that uses React.Component from the react package instead of react-native.
This is confusing since 0.14 release seem to indicate that was exactly the point moving fw. Let React create components, let react-dom deal with the DOM and let react-native deal with ios/android views.
I think this is a brilliant idea but I cant seem to pass this particular problem. Any thoughts, ideas will be greatly appreciated.
Thanks
The transition to make react native work this way is underway but incomplete. See AMA.
We are working hard to stop using our fork such that people can use require('react') and work the same as require('react-native'), this will make it possible for all the third party plugins to work on both places without doing anything.
Right now we can't use relay on the open source version of react-native without forking it, which is a huge shame and we're working on fixing that.

Resources