mirror of
https://github.com/aleleba/create-react-ssr.git
synced 2025-06-20 04:48:30 -06:00
PR-753737: Agregando SSR y React Router.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import PrincipalRoutes from './PrincipalRoutes';
|
||||
|
||||
const App = () => <h1>Hello React!</h1>
|
||||
const App = () => <PrincipalRoutes />
|
||||
|
||||
export default App;
|
5
src/frontend/components/InitialComponent.jsx
Normal file
5
src/frontend/components/InitialComponent.jsx
Normal file
@ -0,0 +1,5 @@
|
||||
import React from 'react';
|
||||
|
||||
const InitialComponent = () => <h1>Hello React!</h1>
|
||||
|
||||
export default InitialComponent;
|
5
src/frontend/components/OtherComponent.jsx
Normal file
5
src/frontend/components/OtherComponent.jsx
Normal file
@ -0,0 +1,5 @@
|
||||
import React from 'react';
|
||||
|
||||
const OtherComponent = () => <h1>Other Component!</h1>
|
||||
|
||||
export default OtherComponent;
|
11
src/frontend/components/PrincipalRoutes.jsx
Normal file
11
src/frontend/components/PrincipalRoutes.jsx
Normal 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;
|
@ -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();
|
||||
|
Reference in New Issue
Block a user