Skip to content

Instantly share code, notes, and snippets.

@ambar
Last active November 6, 2023 05:40
Show Gist options
  • Save ambar/b9609224e392426c164afcf7d7e7bf35 to your computer and use it in GitHub Desktop.
Save ambar/b9609224e392426c164afcf7d7e7bf35 to your computer and use it in GitHub Desktop.
jupyter deno react
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