-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Addon-links: Update linkTo type to accept function #8117
Conversation
This pull request is automatically deployed with Now. Latest deployment for this branch: https://monorepo-git-fork-siadcock-sa-update-linkto-type.storybook.now.sh |
@kroeder @gaetanmaisse @emilio-martinez can you review this? |
Functionality to support navigation by (storyId || kind || kind + storyName || storyName) is now implemented in the linkTo itself. It uses the global scope storyStore & clientApi, which isn't good, but we will refactor that later. The navigate function now refuses to navigate to a story that does not exist. hrefTo function also no longer throws an error when kind isn't provided Add test to assert this functionality actually works
I did some testing and found the addon-link not working correctly. After some experimentation I found that the kind + storyname sometimes broke. especially if kind is not provided. I changed the code so the addon resolves the correct StoryItem from the storystore and gets it's name & kind. If it cannot find a StoryItem, it logs an error and does not navigate,
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What I did
Updates the
linkTo()
type to accept a function as the second parameter. This is inline with the documentation and DefinitelyTyped.How to test
If your answer is yes to any of these, please make sure to include it in your PR.