DEV Community

Cover image for Be careful to use react in Obsidian plugin
LeafChage
LeafChage

Posted on

Be careful to use react in Obsidian plugin

💡You should use v18.* of react and react-dom.

What is the problem

I made an Obsidian plugin to memorize words using note on my vault like Anki.
https://community.obsidian.md/plugins/swipe-words

But I have a problem during the review.

## Code obfuscation

  • Error: Found 3 dynamic <script> element creations
    • Dynamically injecting script elements can load and execute arbitrary external code.

What is that? I don't remember writing that code.

Reason

Features added to react-dom in v19 might be the cause.
(like preinit? I am not sure tho)
document.createElement('script') are called internally in 3 spots in v19.

Solution

You can lower the version to v18*, and you will pass the review🎉

Probably, it will be fine during review in the future because there is a document about how to create obsidian plugin with react.
However, actually, I can't now.
If you want to use v19 features, good luck... ;p

Top comments (0)