Using inertia-links within the storybook framework

Hey there, just wanted to share my experience with storybook - I'm really enjoying it so far!

Currently, I'm facing a challenge while implementing it in my Laravel app with Inertia. I'm trying to render a navigation link component that makes use of the Inertia links wrapper:

The component is registered in storybook, but it's not rendering properly because of how the inertia-link replaces the HTML in the code. I'm wondering if there's a way to import the inertia link into storybook to make rendering possible?

When I manually change the tag in the HTML via inspection to an anchor tag (), the component renders correctly. This indicates that the issue lies with the inertia-link, which has been quite frustrating for me.

I've spent some time on this issue and even tried searching for solutions, but unfortunately haven't found an answer yet :(

I'll definitely keep you posted if I come across any new discoveries.

Edit: After further investigation, I noticed an error message in the console which reinforces my belief that the problem lies with the inertia-link component:

[Vue warn]: Failed to resolve component: Link
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement. 
  at <AppNavLink href="/" > 

The code of the Vue component:

<Link
    class="font-medium uppercase hover:text-blue-600 dark:hover:text-blue-400"
    :class="{
      ' text-blue-500 hover:text-blue-500 dark:hover:text-blue-500': active,
    }"
  >
    <slot />
  </Link>
</template>

<script>
export default {
  props: {
    active: Boolean,
  },
}
</script>

The story:

import NavLink from '../resources/js/components/ui/AppNavLink.vue'
import { Link } from '@inertiajs/inertia-vue3'

//πŸ‘‡ This default export determines where your story goes in the story list
export default {
  /* πŸ‘‡ The title prop is optional.
   * See https://storybook.js.org/docs/vue/configure/overview#configure-story-loading
   * to learn how to generate automatic titles
   */
  title: 'Design System/Navbar link',
  component: NavLink,
  subcomponents: { Link },
}

//πŸ‘‡ We create a β€œtemplate” of how args map to rendering
const Template = (args) => ({
  components: { NavLink, Link },
  setup() {
    //πŸ‘‡ The args will now be passed down to the template
    return { args }
  },
  template: ' <NavLink href=args.href > Posts </NavLink>',
})

export const Default = Template.bind({})

Default.args = {
  /* πŸ‘‡ The args you need here will depend on your component */
  href: '/',
}

Answer β„–1

I think there might be a mistake in your export default declaration. It should look like this:

export default{components: {NavLink, Link}}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

React.js TypeScript Error: Property 'toLowerCase' cannot be used on type 'never'

In my ReactJS project with TSX, I encountered an issue while trying to filter data using multiple key values. The main component Cards.tsx is the parent, and the child component is ShipmentCard.tsx. The error message I'm receiving is 'Property &a ...

Utilizing SlickGrid and DataView for calculating totals efficiently without the need for grouping

I am attempting to utilize Slick Grid and DataView to calculate column totals similar to the example shown here: . However, I do not want to group my rows. Therefore, I attempted not passing a getter and formatter into the dataView.setGrouping(..) method. ...

blur event triggered on a cell within a table

Currently, I am using the code snippet below to populate data using a data table. My goal is to be able to edit the data in one of the columns and then validate the value after editing using the onblur event. I attempted to call the onblur event on the t ...

What is the best way to arrange images in a 3 by 3 grid, beginning at position 0, using JavaScript to control navigation through button clicks?

When I click on button 1, it starts at image 1 because the counter is set to 0. Clicking on button 2 takes me to image 4 with a counter value of 3, while clicking on button 3 leads to image 7 with a counter value of 6. The process should also work in reve ...

Is it possible to compile a .ts file at the root level without following the tsconfig.json configurations?

After dealing with the challenge of having both .ts and .js files coexisting in each folder for months, I have finally managed to get the app to compile correctly. The transition from JS to TS brought about this inconvenience, but the overall benefits make ...

Displaying 'N/A' in the chart if the data is missing

I have a chart that displays data, but when data does not exist it shows "undefined%". Is there a way to remove the "undefined%" and simply display nothing on the graph if no data exists? Here is the code snippet: import { Bar } from "react-chartjs-2"; ...

Refreshing certain sections of a webpage without the need to refresh the entire page

If you want to understand better, it would be helpful if you could check out my website first at: The main part of the website is a stream from Own3D.tv displayed through an iframe (line 342). My objective is to have the ability to click on a specific str ...

Sort users by their data attribute using jQuery

I need to sort users based on their data attribute. Within the main div called user-append, I have a variable number of users retrieved from an ajax get request. It could be 3 users or even up to 100, it's dynamic. Here is the structure with one user ...

Exploring Nested Objects within a v-for Loop

My API is returning an array of objects, where each object has the following structure: { id: 6, typeTitle: 'Type Title goes here', typeImg: 'Some image', typeLink: 'https://www.somewebsite.com', publishDa ...

Reaching the maximum request threshold

Currently, I am facing an issue where users are able to upload files from the client side (using Angular 4) to the server (implemented with Spring Boot). The problem arises when a user attempts to upload more than 6 files at once. In such cases, Chrome uti ...

The submission of FormData to the PHP server is causing an issue

I am having an issue with sending the formData to my PHP script using AJAX. Despite inspecting the elements, I can't find any errors in the process. Below is the structure of my form: The input values are sent to a JS file onclick event. <form c ...

I am currently in the process of cross-referencing the tags that have been retrieved with those that have been selected or created. If a tag does not exist

I have a collection of tags in an object, and I want to dynamically add new tags before submitting the form. Despite using vue watch, it doesn't seem to be working for me. Here is the code snippet: data() { return { blog: { blog_ti ...

Is it possible to halt an animation using a click event in Vuejs?

I have a MainMenuItem component with static titles, except for one variable item dedicated to news and events with a horizontal ticker scroll animation. The click event to stop the animation and change the font weight needs to be triggered from the parent ...

Using jQuery to append text after multiple element values

I currently have price span tags displayed on my website: <div> <span class="priceTitle">10.00</span> </div> <div> <span class="priceTitle">15.00</span> </div> <div> <span class="priceTitle">20.0 ...

When attempting to register a custom Gamepad class using GamepadEvent, the conversion of the value to 'Gamepad' has failed

I have been working on developing a virtual controller in the form of a Gamepad class and registering it. Currently, my implementation is essentially a duplicate of the existing Gamepad class: class CustomController { readonly axes: ReadonlyArray<nu ...

Unexpected JSON token error occurs in jQuery when valid input is provided

I encountered an error that I'm struggling to pinpoint. The issue seems to be related to the presence of the ' symbol in the JSON data. After thoroughly checking, I am positive that the PHP function json_encode is not responsible for adding this ...

Activating and deactivating event capturing in Vue.js

Incorporating Vue.js into my project has been a game-changer. One interesting aspect is the event listener's third option, known as capture. For instance: element.addEventListener("click", function(){}, true); I'm curious if it's ...

What is the best way to compare two times in the hh:mm AM/PM format?

I need to handle times in the format of hh:mm AM/PM generated by a specific plugin, and perform comparisons on them using jQuery/javascript. When a user manually inputs a time, I require the text in the textbox to automatically adjust to hh:mm AM/PM with ...

Is it possible to utilize a Render Function in a .vue Component file?

I am interested in dynamically setting the HTML tags for components. Consider the following example: components: { test: { props: ['tag', 'attributes'], render(createElement) { return createElement(this.tag || ...

Having trouble setting a value as a variable? It seems like the selection process is not functioning properly

My Hangman game has different topics such as cities and animals. When a user selects a topic, the outcome should be a random item from that specific topic. For example: London for cities or Zebra for animals. Currently, I am only generating a random lett ...