React example not work

Hi everyone!

I want to develop a plugin for obsidian and I start to follow the tutorial and everithing is ok.

But I need to implement some custom control and I think to use React because I know a little bit… better than svelte anyway.

but I follow the tutorial: Use React in your plugin - Developer Documentation

and when I mounted view (Use React in your plugin - Developer Documentation) not work.

So… I have some questions:
there is no log to check where the problem is?
why not put a github complete example repo? the error may be a setting thing.
So… maybe React it is not the best choice to develop a plugin with custom command?

if you want I can put a repo in this thread

React should work. Why don’t you share your code?

GitHub - zhouhua/obsidian-export-image this is my project, which using React. Perhaps you can take a look at it for reference.

This is the code: https://github.com/ffex/sample-plugin

The main branch there is two commit:

everything is work.
then I start to follow the react tutorial and when I do “Mount the React component” it didn’t compile and I don’t know where the problem is.

it is in the branch “react-tutorial”

Simply run npm run build to get error messages, and then address them individually to resolve the issues:

1 Like

thanks I’ll try!

I correct errors but nothing… the plugin not work, I push the fixes

Problem was in the file tsconfig.json at

{
  "compilerOptions": {
    "jsx": "preserve"
  }
}

because this is in the documentation and last month was corrected:

{
  "compilerOptions": {
    "jsx": "react-jsx"
  }
}

Now my plugin work :slight_smile: Thanks everyone!