preactjs / preact-router

:earth_americas: URL router for Preact.
http://npm.im/preact-router
MIT License
1.01k stars 156 forks source link

unable to use hooks #375

Closed Th0rgal closed 4 years ago

Th0rgal commented 4 years ago

Hello,

When I'm using a component my page is working: source code: https://github.com/cashplace/client/blob/3317123348ca253b7d378ff0918179d93b386888/cashplace/src/routes/ticket/index.js

But when I'm using a hook, I have an error: source code: https://github.com/cashplace/client/blob/d4c4b44c519f7fbbd74547ae044fa9442fd230ff/cashplace/src/routes/ticket/index.js

error: error

I'm using it that way:

  render() {
    return (
      <div id="app">
        <Header />
        <Router onChange={this.handleRoute}>
          <Home path="/" requestsManager={this.state.requestsManager} />
          <Ticket path="/:id" requestsManager={this.state.requestsManager} />
        </Router>
      </div>
    );
  }

I'm not sure from where this issue comes from. If I didn't open this issue in the right place please tell it to me. Any help is appreciated!

lightdiscord commented 4 years ago

When you import useParams from preact-router here there are multiple problems.