Can we use the React Native component in React - reactjs

Recently I have a requirement where I need to use the react native component in react web app. I have searched and found one component i.e React Native Web.
That converts the react native component to work in react web app. Although I am having some errors but I actually wanted to confirm that whether it is doable to use the react native component in react web app SO that whenever we make changes in React Native Component, that will automatically be handled to be shown in the web. Because for react-native-web, we need to provide the react native file that will be converted into the web view. But how we can make sure that whenever we update the mobile component, changes will automatically be reflected on the web without making any changes.
Any help would be much appreciated.
Thanks

Yeah , U can use react-native-web.
But not all components working in react-native works on react-native-web , so u have to take care of those components and then u can maintain same codebase for both.
Further more, u can refer to https://github.com/necolas/react-native-web modules and components section

Related

How to combine react and react-native projects?

I have created a website with react.js, Material-UI, and node.js. Now I want to create a mobile app for that website with React-native. I have used redux,react-redux, and saga on the website. I am new to react-native.
I want to know, Is it possible to create a mobile app and website in a single project structure, If possible then how? Because I don't want to repeat the same state and API calling procedure two times.
React.js uses HTML to render pages and React native doesn't support HTML so you can't use direct HTML.
You can buy react native theme that suits your need and you can re-use services and api call logic from react code.
Theme: https://codecanyon.net/search/react%20native
You can't just use your whole code into the react native app.
First and foremost, you must adhere to the react native architecture before creating your UI with react native components.
https://reactnative.dev/docs/getting-started
The most of the assistance will be found here.
There is also the option of creating a new react-native project and using webview to show your entire website there.
https://github.com/react-native-webview/react-native-webview

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.

How to use react j s components in react native app?

Is it possible to use all the reactjs components in react native app?If no,what is the best way to switch between react js and react native?
If an app is done using react js is it necessary(Compulsory) to use redux in that?
There are two main points:
1.The base UI components in React (DOM) and React Native are different.
2.The ‘React’ objects in React and React Native are different (React Native removes the DOM-specific stuff adds a lot of native-specific code).
please check this link for more details:
https://medium.com/#aakashns/sharing-components-between-react-and-react-native-f6ce3713658a#.oa4my8p36
I avoid these types of quests because React JS UI components built for the web have different semantics than React JS UI components built for React Native.
React Native doesn't have <div/> or <img/> or a DOM for that matter.
React Native uses React JS components that bind to native views, and things like CSS are so very different than that from the Web.
The only way you'd be able to use a React JS UI component in a React Native app is by making it 100% of the height and width of an embedded webview. It's possible (i've done it for testing purposes), but not ideal.
Is it possible to use all the reactjs components in react native app?
React Native uses other types of components which aren't related to HTML, but to iOS and Android views. Even the styling is slightly different.
If no,what is the best way to switch between react js and react native?
You can still reuse other parts of your code. If you use redux, for example, you should keep using almost the same code.
If an app is done using react js is it necessary(Compulsory) to use redux in that?
No, redux is just an implementation of the flux architecture. There are others, but redux is the most popular one.
If your component contains pure js logic, then yes. React js is meant for Web, where we make use of web semantic. React native extends mobile native UI components.

Are all React components usable in React Native?

There are lots of React components available. How do I know which ones are usable on React Native platform (IOS and Android)?
Web React components use DOM elements to display (ex. div, h1, table, etc) but these are not supported by React Native. You'll need to find libraries/components made specifically for React Native.
I doubt there are components that supports both, thus it should be fairly easy to figure out if it's made for React Native or not. As of now, if the creator does not specifically say that they made for React Native, it probably does not work on React Native.

How to change component in react JS without using navigator?

I'm a newbie for React Native and I don't have native development experience(I only worked on several hybrid apps), while learning this react native framework, I get several questions which block my learning.
How to navigate from one page(component) to another page(component) without relying on navigatorIOS or navigator component? In Hybrid develop mode, it's so easy, just add element A with href attribute would work, but in React Native, how to do it? I read some examples, they all use navigator or navigateIOS component to do it.
Is there any interceptor mechanism in react native so that we could inject some logic before rendering or loading component, for example, we want to have interceptor to check whether user has been login?
How to save data globally (cross components)? In Hybrid mode, we have session, we have local storage, and if we angular JS framework, we could use Service or root Scope to save data, by using react native, how do we save data cross components?
Since I'm new to react native and new to native application development, these questions might be fairly stupid, if anyone could help on this.
I don't know i'm answering to your question but please check this router component for react
https://github.com/rackt/react-router
ComponentWillMount and ComponentDidMount can be used to perform some initial loading
You can use flux framework along with React which can do almost all like in angular js
https://facebook.github.io/flux/

Resources