-
-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Programmatical navigation with preact-iso
is confusing due to the use of the useLocation
hook which is limited by the rules of React hooks, rules that may not be intuitive.
From reading the issues, it seems that this is causing great confusion among users so I suggest a new API to change routes which would be more intuitive for users and would alleviate some of your support burden i.e.
I suggest a new function to navigate to a route that is not limited by the rules of React hooks.
import { pushRoute } from 'preact-iso';
function AnywhereInTheCode() {
// Anywhere in the code, not only in places where hooks can be used
pushRoute('/url');
}
Here are a few ideas of names for this function goTo
, navigate
, pushRoute
.
From my reading of the code
Line 30 in 82cdde4
function handleNav(state, action) { |
route
function from useLocation
does not fundamentally need to be a hook, so we could move it to its own dedicated function.Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request