-
Notifications
You must be signed in to change notification settings - Fork 642
/
app.jsx
31 lines (27 loc) · 891 Bytes
/
app.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import React from 'react';
import Nav from './nav/nav.jsx';
import { render as renderMain } from './Main';
import { createRoot } from 'react-dom/client';
import { Provider } from 'react-redux';
import store from './util/create_store';
// The navbar is its own React element, independent of the
// main React Router-based component tree.
// `nav_root` is present throughout the app, via the Rails view layouts.
const navBar = document.getElementById('nav_root');
if (navBar) {
const navRoot = createRoot(navBar); // createRoot(container!) if you use TypeScript
// Render the Nav component with Redux store
navRoot.render(
<Provider store={store}>
<Nav />
</Provider>
);
}
const reactRoot = document.getElementById('react_root');
if (reactRoot) {
// Render the Main component with the same Redux store and React Router
renderMain(
reactRoot,
store
);
}