PR-753737: Agregando SSR y React Router.

This commit is contained in:
2022-04-17 22:54:45 +00:00
parent 712564e7ca
commit 7e018e2763
14 changed files with 443 additions and 216 deletions

View File

@ -1,5 +1,6 @@
import React from 'react';
import PrincipalRoutes from './PrincipalRoutes';
const App = () => <h1>Hello React!</h1>
const App = () => <PrincipalRoutes />
export default App;

View File

@ -0,0 +1,5 @@
import React from 'react';
const InitialComponent = () => <h1>Hello React!</h1>
export default InitialComponent;

View File

@ -0,0 +1,5 @@
import React from 'react';
const OtherComponent = () => <h1>Other Component!</h1>
export default OtherComponent;

View File

@ -0,0 +1,11 @@
//Router
import { useRoutes } from 'react-router-dom';
//Routes
import routes from '../../routes';
const PrincipalRoutes = () => {
let element = useRoutes(routes);
return element
}
export default PrincipalRoutes;

View File

@ -1,9 +1,21 @@
import React from 'react';
import ReactDom from 'react-dom';
import { createRoot } from 'react-dom/client';
//Router
import { BrowserRouter as Router } from 'react-router-dom';
//History
import { createBrowserHistory } from 'history';
import App from './components/App';
import './styles/global.sass';
ReactDom.render(<App />, document.getElementById('app'));
const container = document.getElementById('app');
const root = createRoot(container);
const history = createBrowserHistory()
root.render(
<Router history={history}>
<App tab="home" />
</Router>
);
if (module.hot) {
module.hot.accept();