Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add basePath to useLink href #503

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexanderjhughes
Copy link

What was changed

  • A basePath check was added to Solito's useLink method

Why this is needed

When configuring a basePath for your app using the NextJs basePath config, Solito for the most part uses it. There is one exception though. That is when Solito's useLink is called and the href is generated. If you click on the element, the onPress takes care of the basePath due to it using NextJs' router under the hood. However, the href is just passed down to the button without NextJs touching it. This fixes that issue.

Screencast.from.02-19-2025.11.39.00.PM.webm

In this screen recording, you can see it going to the correct url. The code for the url is as follows:

import {Button, YStack} from 'tamagui';
import {Layout} from '../../components';
import {useLink} from 'solito/link';

const EventsHomePage = () => {
  const buttonParams = useLink({
    href: '/search',
  });
  return (
    <Layout>
      <YStack jc={'center'} ai={'center'} mt={'$10'} h={'100%'}>
        <Button {...buttonParams}>Click me to go to search</Button>
      </YStack>
    </Layout>
  );
};

export default EventsHomePage;

In this you can see I am not adding the /app route, but now with this change, Solito adds it for me.

Copy link

vercel bot commented Feb 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
solito-app ❌ Failed (Inspect) Feb 20, 2025 4:43am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
solito ⬜️ Ignored (Inspect) Visit Preview Feb 20, 2025 4:43am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant