SolidJSS
SolidJSโ€ข9mo agoโ€ข
5 replies
finn

SolidJS Router Missunderstanding

Can someone help me setup a basic router with the
"@solidjs/router"
I am not sure where to put what. My current understanding was that this is the way to do but document.getElementById is underlined red:
Argument of type 'HTMLElement | null' is not assignable to parameter of type 'MountableElement'.
  Type 'null' is not assignable to type 'MountableElement'


App.tsx
import type { Component } from 'solid-js';
import { render } from "solid-js/web";
import { Router, Route } from "@solidjs/router";

import logo from './logo.svg';
import styles from './App.module.css';

const App: Component = () => {
  return (
    <div class={styles.App}>
      <header class={styles.header}>
        <img src={logo} class={styles.logo} alt="logo" />
        <p>
          Edit <code>src/App.tsx</code> and save to reload.
        </p>
        <a
          class={styles.link}
          href="https://github.com/solidjs/solid"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn Solid
        </a>
      </header>
    </div>
  );
};

render(
  () => <Router root={App}>
    {
    /*... routes */
    }</Router>,
  document.getElementById("app")
);

export default App;
Was this page helpful?