pablo-abc / svelte-markdown

Markdown parser to svelte components
MIT License
359 stars 50 forks source link

<Paragraph> was created with unknown prop 'raw' #36

Closed ceifa closed 2 years ago

ceifa commented 2 years ago

I'm getting this error a lot on svelte-kit: <Paragraph> was created with unknown prop 'raw'

This is probably a bug.

pablo-abc commented 2 years ago

This is not a bug and has been discussed before. Seeing the most recent comments on the linked issue from Svelte, I am thinking that following the workaround from Routify could be done: disabling console.warn completely during the initialisation of our component. I'll toy with that. Feel free to leave this issue open!

ceifa commented 2 years ago

Hey, just saw it was fixed on https://github.com/pablo-abc/svelte-markdown/commit/2125e51a2e6aa7dda574b6a54be61ceeaf38a7dc, very good! It's a great solution but I don't know if it's the best. The difference from svelte-markdown and the Routify is that in Routify the user create the component, since in svelte-markdown all components is in the library maybe we can refact to receive only the props the component needs.

Something like that would work:

{#if type == "paragraph"}
    <svelte:component this={renderer[type]}>
{:else}
   <svelte:component this={renderer[type]} {...$restProps}>
{/if}
pablo-abc commented 2 years ago

Part of the features of this package is that we do allow to write your own components. In the case of paragraph, for example, you might override it with your own component that takes the 'text' or 'raw' prop and does something with this. So unused props are to be expected.

ceifa commented 2 years ago

Oh, thanks for the explanation! :) Closing since it was fixed.