import * as React from 'react'
import * as ReactDOM from 'react-dom'
import { createRoot } from 'react-dom/client'

import { HistoryRouter as Router } from 'redux-first-history/rr6'
import { Provider } from 'react-redux'

import { createBrowserHistory } from 'history'
import configureStore from './store/configureStore'
import { App } from './App'
import registerServiceWorker from './registerServiceWorker'

// Create browser history to use in the Redux store
// Get the application-wide store instance, prepopulating with state from the server where available.
const { store, history } = configureStore( createBrowserHistory(window))

const container = document.getElementById('root')
const root = createRoot(container as HTMLElement)

root.render(
  <Provider store={store}>
    <Router history={history}>
      <App />
    </Router>
  </Provider>)

registerServiceWorker()
