Questions tagged [hookrouter]

17 questions
5
votes
2 answers

Using hookrouter with create-react-app fails to update the view on navigation change

I am attempting to get the most basic example of hookrouter (an alternative routing library to react-router-dom) working and cannot get the page to change. The URL address will change to /about when I click on the /about link but the UI doesn't…
5
votes
2 answers

How to get the current url path using hook router in react?

I'm new to react and react hooks. I'm using hookrouter package and I tried to googling about the question, but didn't find much about it. What I want? I'm trying to get the current url path. For e.g. for https://example.com/users/temp, I want to…
Dhruvil21_04
  • 1,804
  • 2
  • 17
  • 31
4
votes
3 answers

How to pass props through useRoutes in react hook router?

I'm new to react and react hooks. I'm using react-hooks for one of my project. I'm using hookrouter package and I tried to googling about the question, but didn't find much help. What I want? I'm trying to pass props through hook routes in react.…
Dhruvil21_04
  • 1,804
  • 2
  • 17
  • 31
2
votes
1 answer

Hookrouter (react) changes url but not the view, only after refreshing the page by yourself

I was trying using hookrouter instead of react-router, but I faced a problem. I've seen some answers to similar questions, but only for react-router. Moreover, I ended up just copy-pasting this code. const routes = { "/user": () => , …
maulit
  • 21
  • 4
2
votes
1 answer

React Material UI Button component with hookrouter

I am trying to migrate a class component React app to functional components with hooks. When using class components I use to pass a Link component to a Button component since I was using react-router-dom library. But now I am trying to use…
Maramal
  • 3,145
  • 9
  • 46
  • 90
1
vote
1 answer

Clicking on link changes route but not Component itself - React Hook Router

I'm facing the ReactJS routing issue. Working Demo. I'm using the hookrouter package. Issue: As mentioned in the demo, if I'm on the /users route and when I click on about link, the URL changes but About Component is not getting loaded. What I…
Dhruvil21_04
  • 1,804
  • 2
  • 17
  • 31
1
vote
1 answer

How do I make a custom link component with the hookrouter?

I am trying to create a custom router component so that my tr links to another page passing through the data object for that row. When I click the link my not found page comes up, even when I use simple routes like '/'. I also had this issue with…
Quddus George
  • 962
  • 2
  • 14
  • 30
1
vote
1 answer

Can we generate object with jsx fields?

I like to use useRoutes() hook from https://github.com/Paratron/hookrouter but I have too many pages, and get lot of repeating code, I try generate some areas, please help me write genRoutes() function Example code: const pages = [{ name: 'aaa'…
Eugene Balashov
  • 105
  • 1
  • 13
1
vote
1 answer

Context compatible React hook for routing

I'm using hooks and functional components in all my react project and don't have any class component. So i want a hook to use for routing (so don't want to use react-router library). I googled and found some hooks and choose the hookrouter. Since…
Amin
  • 221
  • 3
  • 13
1
vote
2 answers

React Context and hookrouter doesn't redirect on component mount

I am trying to "copy" my real world project with CodeSandbox (here). I have a login form and when login, it sets a cookie with auth data. When the component mounts, it should check for that cookie and redirect back to
Maramal
  • 3,145
  • 9
  • 46
  • 90
0
votes
0 answers

How do you pass a callback function from hookrouter as a property to a react component?

I want to pass a callback function into a component that is a target of a hookrouter route. I have been googling this for some time and the responses are all related to react-router instead. I need info specific to hookrouter. The callback function…
0
votes
0 answers

Pass additional props through hookrouter

I'm trying to pass additional data through to a component using hookrouter. I'm not sure what I'm doing wrong. I get the error Functions are not valid as React child. This may happen if you return a Component instead of from…
bp123
  • 3,217
  • 8
  • 35
  • 74
0
votes
1 answer

What is the Typescript type for a route map object in hookrouter?

How do I replace any for hookrouter?? type RouteMap = Record JSX.Element>; ^^^ Full Code import { useRoutes, usePath, } from 'hookrouter' //// HOW DO I REPLACE any??? type…
merry-go-round
  • 4,533
  • 10
  • 54
  • 102
0
votes
1 answer

How to remove incorrect route from browser's address bar and redirect to Home route in hookrouter?

Please check the following Code Sandbox: https://codesandbox.io/s/react-router-demo-hook-switch-alternative-nfqew?from-embed In this, when we enter an incorrect route, it loads 'NoPageFound' component. Instead of this, when an incorrect router is…
MAK
  • 1,915
  • 4
  • 20
  • 44
0
votes
1 answer

How to listen to route change in hookrouter - React

I know that react-router provides onChange attribute to listen to route change, but I'm using hookrouter package (doc). I'm trying to get a log of users when they visit a specific route. For e.g. when they visit /aboutus route. The user could visit…
Dhruvil21_04
  • 1,804
  • 2
  • 17
  • 31
1
2