-
Notifications
You must be signed in to change notification settings - Fork 766
feat: add mathjax lib using useScript #2839
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
frontend/src/hooks/useScript.ts
Outdated
| src: string, | ||
| options: ScriptOptions = defaultOptions, | ||
| ) { | ||
| const [status, setStatus] = React.useState<ScriptStatus>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in order to avoid an extra render, can you actually check the status from the start
useState<ScriptStatus>(() => {
return document.querySelector(`script[src="${src}"]`)?.dataset.status ?? 'loading'l
})
frontend/src/hooks/useScript.ts
Outdated
|
|
||
| if (script) { | ||
| const domStatus = script.dataset.status; | ||
| if (domStatus) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we end early and not observer if its already 'ready'/errored?
mscolnick
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work, looks great!
|
sorry I missed out the earlier stuff, you're right on the rerenders! Do you think I should add tests? I'm looking into it |
|
@Light2Dark - up to you if you want to add a test. our hook tests have been pretty minimal, but i have found Claude to be pretty good at writing tests for hooks (smaller than this). in short: if its painless and easy, please do, otherwise don't stress over it |
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.9.19-dev5 |
📝 Summary
Fixes #2060 . Adding MathJax library in PlotlyPlugin to render LaTeX for Plotly.
🔍 Description of Changes
useScriptat the same time📋 Checklist
📜 Reviewers
WIP