I currently have separate libs for React and React-native, is there any way to have the same library working on both platforms. Foe example, is there a way to use react-native web on normal react project?
(I am considering code sharing but other than that I did not found anything useful on the net.)
Related
I wrote electron.js multi-window application using native javascript. I want to rewrite this app using one of javascript framework like React, Vue or Angular. They are SPA frameworks so I predict, that one instance corresponds to one window. I think that Angular may be too large for smaller windows.
My app currently has one main window (that executes a lot of code) and three smaller, so I don't want to use too big frameworks for them. One more question: all of those framewoks are compatybile with typescript?
I have built a multi-window (multi-page) Electron app using both Bootstrap and Angular and had no issues.
You can get Typescript definitions for React / Bootstrap here or (for Bootstrap) here.
A tutorial for using Typescript with Angular can be found here. It is a little dated but should be a good starting point.
This question in stackoverflow also has some useful information that you may find helpful.
I have found a p5 JS wrapper for react (react-p5-wrapper) . Is there any way to implement p5 in react native app too ?
I'm afraid there's no way at the moment.
I just checked the GitHub repo of p5.js and it uses DOM elements (like canvas) in its source code (for example https://github.com/processing/p5.js/blob/master/src/image/image.js).
React Native doesn't have a DOM, so that's not possible (except maybe using a WebView or jsdom, but what's the point using RN then?).
I think you'll have to wait till someone makes a fork especially for React Native.
I would like to use pspdfkit with React in electron. I am not sure how I could do this. I know there is a React native wrapper available, but I am not sure whether this is of any use to me, since I am not using React native, but React & electron.
On the other hand, there seems to be a web version available, but the only example given on their website is with docker. I would like to integrate it into my React / electron app, not have it run on localhost:XXXX in a browser.
Any advice on how I could approach this, generally speaking?
PSPDFKit Founder and CEO here.
What you are looking for is an Offline-Version of PSPDFKit for Web. This is a separate framework that works standalone and doesn't need a Server-Component to render PDF documents. We're already working on that. Stay tuned!
Happy to discuss this more: peter at pspdfkit dot com
Edit: https://pspdfkit.com/guides/ios/current/other-languages/electron/
I am new to React JS. I am trying to build a web application which should also work on mobile (Android and IOS) so thought of using react js for web application and created few components. so is it possible to use the React js component in React native.
It's good that you plan in advance. 100% matching between JS and Native won't be possible, but with careful planning, you could get to reuse a good deal.
You may want to take a look at React Native Web project that mirrors Native-specific components for Web (e.g. View, Image, Text, etc).
I suggest building a simple prototype in React JS and then in React Native so you get some understanding of the differences in the two ecosystems. Having a hands on experience will prove more beneficial than any writeup :)
ReactNative is a set of real native Components like View, TextInput TouchableHighlight and more. It is also a platform which let you run javascript code to control these.
There is no WebView like in Cordova, what you get is a native App with native views.
But that means, that you can still have some or your domain logic written in JS which you can use the same way in your Web App.
For example you have a Login Screen for iOS, but all the necessary stuff for your server calls, can go into a separate module e.g. api/auth.js, which is shareable between web, ios, android, iot.. what ever.
I want to reuse some code that retrieves data from an API for two apps. One is an iOS app using React Native. The other one is a website using React.js.
I initially coded the class that retrieves data from an API when I built the iOS app. Thus, I used the fetch method available in React Native.
Unfortunately, there isn't such a method in React.js.
My best option if I want to reuse my code is to abstract the call of the React Native's fetch method by creating a class HTTPRequests with a method fetch which will call the React Native's fetch method or the '$.get' method depending on the lib used by the project: React.js or React Native.
My question is the following: How can I detect the using of React.js or React Native in my project. My first idea is to detect if my JS code is executed through RCTRootView engine or a browser. But I've no idea how to accomplish this.
Any suggestion?
Thanks!
My suggestion would be to move shared logic into separate module (bower, npm, ES6), generalize the way you request data through fetch polyfill, and never ever bother with detecting React/React.native in your project. JS code detection will make your code unnecessary complicated and hard to support when new versions of React/React.native will come up.
I have successful experience of building a cross-platform application with React and React Native using the platform-specific extensions feature of React Native. I've just described how I structured the code in order to achieve that in a blog post Code sharing between React and React Native applications