React onClick не запускает компонент
Я использую Remix с React и TS. У меня есть простой компонент класса Map.tsx, который используется в index.tsx.
Map.tsx
class Map extends React.Component {
constructor(props: any) {
super(props);
this.regionClicked = this.regionClicked.bind(this);
}
render() {
return (
<div>
<button onClick={() => alert("ciao")}>a</button>
</div>
)
}
}
index.tsx
import Map from "../components/index/map/Map";
class Index extends React.Component {
constructor(props: any) {
super(props);
}
render() {
return (
<div>
<Map />
</div>
)
}
}
1 ответ
Исправлено с помощью тега Scripts в файле root.tsx. Пример доступен здесь
import { Scripts } from "remix";
function Document({ children }: { children: React.ReactNode; title?: string }) {
return (
<html lang="en">
<head>
<Meta />
<Links />
</head>
<body>
<Header />
{children}
<Footer />
<Scripts />
{process.env.NODE_ENV === "development" ? <LiveReload /> : null}
</body>
</html>
);
}