oedotme / generouted

Generated file-based routes for Vite
https://stackblitz.com/github.com/oedotme/generouted/tree/main/explorer
MIT License
1.06k stars 50 forks source link

createRoot(...): Target container is not a DOM element. #99

Closed mweel1 closed 1 year ago

mweel1 commented 1 year ago

Describe the Bug

image

Tried 1.14.x got the same thing.

main.tsx

import { createRoot } from "react-dom/client";
import { Routes } from "@generouted/react-router";
// import { Routes } from '@generouted/react-router/lazy' // route-based code-splitting

const container = document.getElementById("app")!;
createRoot(container).render(<Routes />);

Its generating my ./router.ts file ok.

// Generouted, changes to this file will be overriden
/* eslint-disable */

import { components, hooks, utils } from '@generouted/react-router/client'

export type Path =
  | `/`
  | `/patient`

export type Params = {

}

export type ModalPath = never

export const { Link, Navigate } = components<Path, Params>()
export const { useModals, useNavigate, useParams } = hooks<Path, Params, ModalPath>()
export const { redirect } = utils<Path, Params>()

Generouted Version

1.15.0

Your Example Website or App or Reproduction

n/a

Steps to Reproduce the Bug or Issue

Followed the documentation

Expected Behavior

Router to fire up.

Screenshots or Videos

No response

Platform

macOS Chrome

Additional context

No response

mweel1 commented 1 year ago

This happened because my index.html was using id="root" instead of id="app".

This was a standard vite install, so not sure if app is the right default or not?

oedotme commented 1 year ago

Hey @mweel1, thanks for pointing out that. I'll probably add a note about the app/root element or update the getting started examples.