The idea is to make it possible for the user to configure a callback function that determines which component is to be considered a match in case multiple components match by name. By default, a function that chooses the first in the list is provided - this should ensure full backwards compatibility.
As an example, I use a match function that tries to choose the right component based on the contextPath of the component and the story filename, assuming that the closer the story and the component is in the file structure the more likely it is they are related. I use a function like
This PR attempts to fix issue https://github.com/atanasster/storybook-addon-deps/issues/13
The idea is to make it possible for the user to configure a callback function that determines which component is to be considered a match in case multiple components match by name. By default, a function that chooses the first in the list is provided - this should ensure full backwards compatibility.
As an example, I use a
match
function that tries to choose the right component based on thecontextPath
of the component and the story filename, assuming that the closer the story and the component is in the file structure the more likely it is they are related. I use a function like