import React from "react";
import { createHashRouter, RouterProvider } from "react-router-dom";
import { useModel } from "@/store";
import { defaultRoutes } from './routes';

export default (props) => {
  const { routes } = useModel('user');

  const router = React.useMemo(() => {
    if (!routes || routes.length < 1) {
      return createHashRouter(defaultRoutes);
    } else {
      return createHashRouter(routes);
    }
  }, [routes]);

  return <RouterProvider router={router} />
}
