share.jsx 721 B

123456789101112131415161718192021222324252627282930
  1. import './public-path';
  2. import { createRoot } from 'react-dom/client';
  3. import { start } from '../mastodon/common';
  4. import ComposeContainer from '../mastodon/containers/compose_container';
  5. import { loadPolyfills } from '../mastodon/polyfills';
  6. import ready from '../mastodon/ready';
  7. start();
  8. function loaded() {
  9. const mountNode = document.getElementById('mastodon-compose');
  10. if (mountNode) {
  11. const attr = mountNode.getAttribute('data-props');
  12. if(!attr) return;
  13. const props = JSON.parse(attr);
  14. const root = createRoot(mountNode);
  15. root.render(<ComposeContainer {...props} />);
  16. }
  17. }
  18. function main() {
  19. ready(loaded);
  20. }
  21. loadPolyfills().then(main).catch(error => {
  22. console.error(error);
  23. });