-
Notifications
You must be signed in to change notification settings - Fork 440
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
ViewType caption typing is incorrect #367
Comments
We do also support HTML elements as of 1.1.3 (if I set that up correctly). I'm not very familiar with typing, to be honest, but if there's a way to state that, that would be fab. |
Hey @davwheat - thanks for the reply. Your work does support HTML strings correctly, but the bug here is that the {ParseHtml(`<span>${caption}</span>`)} // Footer.js:105 Because the argument to ParseHtml is using the string interpolation, My PR #368 is intended as a bandaid over this until the line in Footer.js can be fixed. Ideally, we'd move it so that the footer's caption is rendered kinda like this: {(caption instanceof string) ? ParseHtml(`<span>${caption}</span>`) : caption} This way we'd render using ParseHtml if it was a string or an HTML rendered string, but we'd just hand it off to JSX to render if it was any other type. I didn't want to make that change as my first PR, though, cause I'm still learning how your codebase is laid out and wasn't sure if it would have unexpected consequences. |
It shouldn't have any issues changing it to that. This isn't my project and, to be honest, I don't even understand how this codebase is laid out! 😅 Previously, that line was just The change to using PS: I forgot to say thank you for the PR, so... thank you! |
Oh zero worries! I agree it sounds like I can safely make this the smarter if/else render. Will update the PR with that. |
Hey, we ran into another problem with The package is declared globally which uses the document unsafetly. Using the current version of There will be another PR to fix this issue soon. We are working on it. |
@florianuphoff Interesting - I'm using it for a SSR here and I'm not seeing any issue with it? Can you open a new issue with the problem you're seeing (and so we can track this separately from this issue which I think we're about to close)? |
@zackdotcomputer Sure - my coworker is going to create one. |
Because of how Captions are rendered by default, the typing of
caption
asReactNode
is incorrect. This includes object types like arrays andReact.Component
types. If you try passing one of these as the caption, however, it renders as[Object object]
rather than rendering properly.What it should be instead is
string | number | boolean | null | undefined
- the primitive types that react can render. I'll open a PR to fix.It would be great if we got support in the future for fully dynamic captions using React Components, but for now this is a much quicker fix.
The text was updated successfully, but these errors were encountered: