简体   繁体   中英

how to use redux or any other state management libraries with react using cdn

So I have a corporate laptop and I can't install npm in that, that's why I have been using react with cdn. I'm facing some problems with updating states in my project so I decided to use a state management library, I did find the cdn link but I can't find any tutorial or materials on how to use the library using a cdn. I'm new to the js ecosystem and really need some pointers on the starting direction. For eg: import {observable} from 'mobx-react' doesn't work with cdn. It gives the error: Uncaught ReferenceError: require is not defined

add the cdn script in the head tag of index.html to make it work:

to use mobx v 6.6.2 :

<script src="https://cdnjs.cloudflare.com/ajax/libs/mobx/6.6.2/mobx.umd.production.min.js" integrity="sha512-eIWf4utGE5IvRknZTPJQurSa6SKD8gT4B430UugX3afhpnjNqQ0fAY6/1rfPNro+8pwVd3bWaMTovLMoIgYWEw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

for other versions you can see the cdnjs doc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM