I have some problem with figouring out how to solve this.
I need to build some cross app library in ReactJs. Something like jQuery but simpler. Library will be adding HTML element to the DOM of the page on which the library was added.
The case is that when for example page with implemented library is simple static page written in HTML only without ReactJs on it the library need to add React and this missing HTML element.
Finally the library need to be hosted on some CDN not as npm package.
Any idea how to make it work? Is it possible to do?
Any ideas are welcome
Related
I'm beginner and learning using React.js. I want to know if I compile react to bundle.js can it work to Wordpress or another php site?
I just need information about it for my current project. Thanks
I don't really know what your idea and why you want to do it.
The main problem is in routing.
Wordpress is CMS with own routing/permalinks system where every created post type has unique url.
If you're building SPA with React routing, you cannot use it together with Wordpress. This would work only on separate domains/subdomains (one for Wordpress and one for React.js app) and communicate across Rest API.
If your React.js app doesn't have own routing, you can use it with Wordpress. You can easily add specific HTML element to your Wordpress post type (by default it is <div id="root"></div> - you can find where is app binded in your index.js/.tsx file), where will be rendered your React.js app and insert link of bundle script to footer of your Wordpress site.
So, imagine that your React.js app is something like "same-origin iframe", which you can add to your website.
If my answer didn't help you, please add more information.
I've created a web application using HTML, CSS and Javascript but is it possible to convert it to a react-native app with the help of any kind of wrapper for HTML, CSS and JS code which can be used within react-native. I would like to convert the web application component into react-native components though it would be a tedious process if I need to change anything in the web application which in turn lead me to change the react-native components.
You cannot use html,css,and javascript code for react native app. Beacause react native has its own tags so it wouldn't possible but still if you can follow the attached url hope it may give you ideas
https://medium.com/javascript-in-plain-english/how-to-convert-any-web-page-to-reactjs-9740f1ba15db
a method would be...
react-native-WebView? I haven't tried it out but from what it sounds like I think its like android web view where u can give it a link and it will load that webpage? that's the closest thing I can think of. of course this method has limitations obviously...
I don't think there are any good methods to turn react code to react-native code since both have different tags and even if you do somehow do it you will have to climb mountains of bugs and fixes if your app is kind of complex.
but if in the future u do take up a project that is for both web and native, and they both share a load of functionality I would recommend something like react-native-web where you can share a codebase between web and native. essentially by making a native app ur making a web app aswell. its a bit tricky when u start but if your having projects like this it will be helpful. hope this gives u some ideas
We are creating one project in angular 7. We want to use jquery based library as image picker.
We have imported the library correctly as
import * as 'image-picker' from '..asset/image-picker.min.js'
Also it has been imported as script in index.js with correct path.
Now we are getting stuck about the correct use of this file in Typescript environment.
For example how to use the below example method of the above library in
Angular Module in component and templates.
You CANNOT use jquery based libs in Angular context.
It was clearly not a good practice with the old fashionned AngularJS 1.**, now it's not even possible.
EDIT :
According to this source, it's seem's possible.
But for me, it's clearly not a good idea to insist on using Jquery with Angular 7
I saw this library using jquery so
If you using external library you need to include script of that library in your website using script tag or if you using angular cli you need to edit your angular.json and include that script
then use it in your method
$("select").imagepicker()
You can go to my blog to read detail how to integrate third party library to angular here
I've been trying to get jQuery datatables to work in a react component. My app doesn't use bootstrap but I want to use it for my tables so I've scoped bootstrap to a class so i can use it in a div without affecting the rest of the application.
I read the following article Integrating React and Datatables — not as hard as advertised, but the article presents a use case that is more basic than I think many jQuery datatables users use. npm datatables doesn't give you access to extensions (search, scroller, button functions, etc), and everything that comes without the extensions is easy enough that you might as well use an existing react table like primereact, react-table, griddle, react-data-grid, reactabular, fixed-data-table, or react-virtualized.
These offer many options but when tested, had at least 1 or more problems that prevented it from being easily adopted and use all the features needed. Some have issues i think I could help fix after I'm more seasoned with react, but I'm not there yet. I've used jQuery datatables in many production environments without any problems. It's a major sticking point moving to react.
So after weeks of searching and testing and trying to work through bugs, I'm back to trying to bring jQuery datatables into my react app. I realize it's not the "react way" but based on the react docs it's possible and there's a proper way to approach it. I don't need it to react with anything outside of its container or div i place it in.
Using the builder is the recommended way to download datatables so you can get your customized components. I'm also downloading rather than using the CDN because this is a local app and needs to work when there is LAN but no WAN access. I'm using create-react-app and I tried to download datatables from here to a folder in my project and had the following problems:
hot-reload started taking forever (>1min)
the page itself was moving at a crawl
extensions didn't seem to be working (could have been locked up?)
How do you use jQuery datatables in a react app while still being able to use the datatables extensions and without killing the hot-reload for create-react-app? Can anyone provide a working example?
Update
Apparently jQuery datatables has made some major updates since the last time I tried to use their builder and now it includes a way to npm install the extensions too. I'll post a github of a working solution if i find one before someone else can update.
Update
Here is a github i made of a react version that is partially working and a basic html/js/css version that is fully working. The readme tells what is working and not working. Can anyone show me why this not working properly?
I am using React native to create an iOS app; So my code is in javascript and some objective-c.
Now i wan't to implement KISSmetrics in my project, i have done the proper setup based on kissmetrics documentation, but when it comes to create events and user identifications etc… i have to use data from my javascript code.
Does anyone knows how to do that? for example:
the objective-c code to identify the user is this: [[KISSmetricsAPI sharedAPI] identify:#"name#email.com"]; but how can i get the code that gets the identity of the user and replace the name#email.com from my javascript code?
I would look here to find out how to build a native module bridge. The way it works is that you create an iOS native module with methods that you can actually call from JavaScript by which you can send your data from JS to Obj-C.
Here's an example project that does this:
https://github.com/idehub/react-native-google-analytics-bridge
You don't need to turn it into a full-fledged NPM library, you can just simply create the necessary native files and JS files on the fly in your project.
Also, if you don't know already, remember to rebuild the iOS project (hit the Play button) to see your changes because the native side doesn't have Live Reloading.