How can I pass an MDX or React component as a parameter of an addon in MDX Stories? #14540
Unanswered
wagedomain
asked this question in
Help
Replies: 1 comment 1 reply
-
You can't serialize this complex functions/data across the channel, so there are a few ways to go. A) Find a format that you can serialize and use that (e.g. a markdown string that then gets interpreted on the manager side) B) Update your requirements/design so that you are rendering it in addon-docs, instead of in its own addon panel. Addon-docs renders in the preview not the manager. C) Register the data in
and then set the keys as parameters:
And then your addon can use the parameter to fetch the right renderer from the registry. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Long story short, I want to build an addon for my org that takes in one (or more) components as params to render. These components can be React components or MDX references.
I can pass in components, but they are not renderable in the addon. Here's a basic rundown of what I want to do in code:
However, when using useParameter inside of register.js, it gives me a set of errors, the first and most significant being:
I've tried using parameters, and channels to do this, and the same thing each time. Direct importing in the register.js file works, but it is not dynamic and thus a dealbreaker. We want users to be able to pass MDX files into the addon.
How can I accomplish this? I have tried serializing the files before and deserializing internally, with no luck (MDX is surprisingly tough to work with) and we've found the documentation for useParameter and useChannel to be severely lacking as well.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions