I’m starting to get to grips with React integration into Sage11.
Initially I was looking at non Sage based tutorials that were all suggesting the use of @wordpress/element - but I haven’t been able to get this to work with Sage, not really sure why but I was getting errors with .jsx files. I then came across this post How to add React support in Sage 11 and I’ve managed to get it working, so I’m pleased.
I’m not a massive fan however of doing stuff without understanding the reasons behind it so I do have a few questions…
During the setup process I installed @vitejs/plugin-react, react and react-dom - so my understanding is that this is full fat React, not WordPress’ bundled version of React (@wordpress/element) - whats the difference and is this better or worse?
What is @vitejs/plugin-react and what does it actually do?
I’m importing it into vite.config.js - does this bit: plugins: [react()] - actually load the plugin into Vite?
In my app.blade.php I’ve added @viteReactRefresh above the line that starts with @vite - whats that for?
Thank you!