Subdomain in Flow or Iron or React Router - react-router

Is there any way that we can implement subdomains in flow or iron or react router?
like, app.domain.com / team1.domain.com / team2.domain.com

Related

How do I embed an external HTML from a web app into a shadow DOM in another web app?

Here's how I've done it. I've created 2 web apps.
Web app 1 hosted on localhost 8081 using a Web Component to embed the 2nd app in a shadow DOM.
Web app 2 hosted on localhost 4200 serving a simple Angular starter app.
Here's how I tried embedding Web app 2 within Web app 1's shadow DOM.
const url = 'http://localhost:4200'; // angular starter app
fetch(url)
.then(response => response.text())
.then(html -> {
const shadow = this.container.attachShadow({mode: 'open'}); // container is just a div
shadow.innerHTML = html;
});
I ended up with the following DOM structure.
As it shows, the resources from Web app 2 are being resolved to Web app 1's base URL localhost 8081 which will fail to load as these resources are located at localhost 4200.
Am I doing something wrong? Is this even a good use case for using shadow DOM instead of using the old-fashioned iframe way for embedding another web app?
I've read some articles like this implying shadow DOM to be the right tool (or a substitute for iframe) for embedding external contents though doesn't really say if the contents need to be free from JavaScript or other external resources to make it work.

How to use react on new web pages after the default

I created a new project using react. After the first page(landing) for which java script and react is already linked to the webpage how can I use my old react elements and new one on the consecutive pages.
If you are loading a completely new page: The same way.
You create a React application, and then initialize it on the page with something like:
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
Typically, however, you wouldn't load a new page.
The user would interact with the React app, and your code would change the state which would change what was displayed on the page. This can be combined with React Router to create deep links into the application and some kind of server-side rendering (such as Next.js) to make those deep links work in an accessible and SEO friendly way.

Best way to render React Components inside HTML templates?

I would like to to use React with Django non Single Page App way - Django will take care of routing, and rendering HTML templates and serving data.
React should be used just on some specific components inside HTML page for eg. (dropdowns, autocomplete, modals), ideally being able to just drop for eg. div element with a class inside HTML and pass props for React component.
What’s the best - maintainable, scalable solution to go about this ?
See django-jsx package and also server side rendering paper. I'm not a frontend specialist but when I've faced such problem, my friends offered me to google isomorphic app with django and react.
I found this add React to an HTML page in one minute page/example to be absolutely painless in rendering a React component inside of a Django template!
This probably isn't what you want to do, given that React has a pretty robust ecosystem around it for building performant single page applications (SPA's). You should be able to decouple your React site from your Django app. Then you'd be able to throw up your React app on a performant CDN, rather than having your Django server hosting every visitor.
But if you insist, the most straightforward way to proceed would probably be to create an index.js & index.html at each Django route. In other words, make a separate "React app" at each route, which Django will serve as users go to each endpoint. I've seen this done before. It's laggy and inefficient (relative to an SPA), but can be done.
If you really intend to go so far as to write raw HTML/CSS/JS and just use React for bits and pieces in between, you'll probably be looking to invoke ReactDOM.render using a variety of second arguments (called container) rather than the standard React-y way of doing a single ReactDOM.render(<App />, document.getElementById('root')); for the whole app to inject into a barebones HTML template.
I notice you tagged your question with server side rendering. If that is a hard requirement for you for some reason, I'd look into using next.js, a Node framework optimized for exactly that.

React, react routing and HTML templates

I am working among a team on a large web projet.
These are the technologies involved:
Meteor: Full-stack JavaScript framework
MongoDB: DBMS
React: included in Meteor as the following 2 main packages react v15.6.1 and react-router-dom v4.1.2
My question concerns the front-end part of the website and its integration with already developed early versions. The specifications of the front-end section were translated to hand drawn wireframes first, then digital ones using Balsamiq.
While developing the first versions of the website, I used React and now I am in love with it (and kind of stuck with it too to be honest :D).
I am not normally in charge of the front-end section of the project, but I will be responsible or integrating it with my already done work.
Knowing that the digital wireframes will be coded in HTML, CSS and JavaScript, my question is: Is there a way of integrating/translating/rewriting an HTML, CSS and JavaScript template to fit React?
My question basically boils down to; how to integrate an HTML, CSS and JS template into a React project?
If there is no way to do so, what would be the best approach: rewrite my code, or the template should be written in React?
What I usually do, is copy the HTML tags/elements from the file into React's return(){} and then add React components and modify some css to make it look like you want it to. Remember, React's return(){} is basically rendering HTML plus your own React components and Javascript to make them work the way you want them to.
However, if you just want to display a page, you can always
import React, { Component, PropTypes } from 'react';
static contextTypes = {
router: PropTypes.object
}
this.context.router.push('/page');
and set the path to direct to the HTML page in your route.js file.

Onsen - UI/HTML5 with React Native

Is there a way to use Onsen-UI as a UI front end, or just regular HTML5, with React Native?
I know React Native was meant to be used alongside React.js, but there's two reasons why I'd like to use a different front end framework like Onsen or Ionic. The first being the fact that I don't want to learn a new framework right now, I don't have the time. And second, I have existing Cordova based apps built with Onsen which I'd like to move over onto React Native.
Thanks in advance.
Onsen UI provides React components. Some of them are very similar to the React Native components.
Here are the docs for the Onsen UI React components: https://onsen.io/v2/docs/react/navigator.html
Onsen UI is a web library for Cordova. so it can't be used to render into Native components. Of course, you can use Onsen UI with React inside a WebView in a native app.