FrintJS
Published in

FrintJS

Rendering FrintJS Apps with React.js in the Browser and Server

I spent more time on this image than writing this post =D

Rendering with react-dom

import React from 'react';
import { render } from 'react-dom';
function MyComponent() {
return <p>Hello World</p>;
}
render(
<MyComponent />,
document.getElementById('root')
);
<div id="root"></div>

Rendering with frint-react

import { createApp } from 'frint';const App = createApp({
name: 'MyApp',
});
import { createApp } from 'frint';
import React from 'react';
function MyComponent() {
return <p>Hello World!</p>;
}
const App = createApp({
name: 'MyApp',
providers: [
{
name: 'component',
useValue: MyComponent,
},

],
});

Rendering:

import { render } from 'frint-react';const App = createApp({ ... });const app = new App();
render(
app,
document.getElementById('root')
);

What about server-side rendering?

import { renderToString } from 'frint-react-server'const App = createApp({ ... });const app = new App();
const html = renderToString(app);

Why not just use ReactDOM directly?

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store