import React from "react";
import { render } from "react-dom";

import { Provider } from "react-redux";

import App from "./App";
import { store } from "./store/store";

let appElement = (
  <Provider store={store}>
    <App />
  </Provider>
);

if (typeof window === "object") {
  if (!window.Element.prototype.closest) {
    window.Element.prototype.closest = function(selector) {
      var element = this;
      while (element) {
        if (element.matches(selector)) {
          return element;
        }
        element = element.parentElement;
      }
      return null;
    };
  }
  window.store = store;

  render(appElement, document.getElementById("root"));

  appElement = null;
}

export default appElement;
