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

<DefaultListItem> was created with unknown prop 'portableText' #10

Open
kamerat opened this issue May 29, 2022 · 3 comments
Open

<DefaultListItem> was created with unknown prop 'portableText' #10

kamerat opened this issue May 29, 2022 · 3 comments

Comments

@kamerat
Copy link

kamerat commented May 29, 2022

Warning comes when using a bullet list.

The Issue is that your component defaultListItem does not have the prop portableText present:

This will cause svelte to trigger a console warning if in development mode.

There is no trivial way to disable this locally as of writing this. There is an ongoing discussion in the svelte repo where people is wishing for an option to disable this.

Even if we were able to disable this warning, I think it is still an issue that the item gets these props when there's nothing the component does with them. I think the best solution here would be to not add the props in the first place.

@kamerat
Copy link
Author

kamerat commented Oct 18, 2022

There is a workaround one can do as we wait for svelte to allow for ignore these warnings or for this repo to fix not sending the prop.

Since the defaultListItem is just a li with a slot, we can recreate it ourselfs and add a unused prop portableText:

<!-- CustomDefaultListItem.svelte -->
<script lang="ts">
    export let portableText = null
</script>

<li><slot/></li>
<!-- myComponent.svelte -->
<script lang="ts">
    import { PortableText } from '@portabletext/svelte'
    import CustomDefaultListItem from "./CustomDefaultListItem.svelte";
</script>

<PortableText
    value={content}
    components={{
        listItem: {
            bullet: CustomDefaultListItem,
            number: CustomDefaultListItem,
        }
    }}
/>

@StanSkrivanek
Copy link

StanSkrivanek commented Mar 24, 2024

Still struggle with this "warning" as solution above does not work for me.

@binoy14
Copy link

binoy14 commented May 9, 2024

Setting it as const and null made the warning go away for me and svelte-check also doesn't complain. Code below

<script lang="ts">
  export const portableText = null;
</script>

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

No branches or pull requests

3 participants