mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-26 06:47:17 +10:00
Make app entry point Universal
- Render to DOM in a browser - Export a render function for the server
This commit is contained in:
parent
5f38b1d74f
commit
089910cf4e
1 changed files with 11 additions and 4 deletions
15
src/index.js
15
src/index.js
|
|
@ -1,9 +1,16 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { renderToString } from 'react-dom/server';
|
||||
import App from './App';
|
||||
import './index.css';
|
||||
|
||||
ReactDOM.render(
|
||||
<App />,
|
||||
document.getElementById('root')
|
||||
);
|
||||
if (typeof window !== 'undefined') {
|
||||
ReactDOM.render(
|
||||
<App />,
|
||||
document.getElementById('root')
|
||||
);
|
||||
}
|
||||
|
||||
export default function render() {
|
||||
return renderToString(<App />);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue