Last active
December 13, 2024 04:14
-
-
Save ambar/b9609224e392426c164afcf7d7e7bf35 to your computer and use it in GitHub Desktop.
jupyter deno react
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'npm:react'; | |
import ReactDOM from 'npm:react-dom/server'; | |
// https://docs.jupyter.org/en/latest/reference/mimetype.html | |
const inspect = (obj: any) => { | |
if (React.isValidElement(obj)) { | |
return { | |
[Symbol.for('Jupyter.display')]() { | |
return { | |
'text/html': ReactDOM.renderToString(obj), | |
}; | |
}, | |
}; | |
} | |
return obj | |
}; | |
inspect( | |
<> | |
<em>Hi:</em> | |
<img src="https://api.iconify.design/fluent-emoji-flat/alarm-clock.svg" /> | |
</> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment