molefrog / wouter

🥢 A minimalist-friendly ~2.1KB routing for React and Preact
https://npm.im/wouter
The Unlicense
6.65k stars 152 forks source link

Uncaught TypeError: Cannot read properties of undefined (reading 'context') #439

Closed crazyming9528 closed 5 months ago

crazyming9528 commented 5 months ago

version :
"preact": "10.20.2", "wouter-preact": "3.1.1"

have error:

bundle.js:1887 Uncaught TypeError: Cannot read properties of undefined (reading 'context')

at P (hooks.module.js:115:13)
at useRouter (index.js:71:81)
at d.Router [as constructor] (index.js:132:19)
at d.O [as render] (preact.module.js:273:15)
at j (preact.module.js:206:38)
at w (preact.module.js:118:5)
at j (preact.module.js:208:245)
at w (preact.module.js:118:5)
at j (preact.module.js:208:245)
at w (preact.module.js:118:5)

my code:

import React, { Suspense, lazy } from 'react';
import { Router, Route, Switch } from 'wouter-preact';
import { useHashLocation } from 'wouter-preact/use-hash-location';

const LazyHome = lazy(() => import('../pages/home'));

export const App = () => (
  <Suspense fallback={null}>
    <Router hook={useHashLocation}>
      <Switch>
        <Route path="/" component={LazyHome} />
      </Switch>
    </Router>
  </Suspense>
);
crazyming9528 commented 5 months ago

it's my reason