简体   繁体   中英

How to use Reactstrap using CDN links

I'm using React with the CDN links, and have realized after a bit of a headache that I need to understand what is the global variable that has been configured for each library in order to use them.

For example in React-Redux, instead of:

import {connect} from 'react-redux'

Which would result in:

Uncaught TypeError: Failed to resolve module specifier "react-redux". Relative references must start with either "/", "./", or "../".

I need to do:

export default connect(mapStateToProps, mapDispatchToProps)(Component)

Like I need to do with React.Component .

Which makes sense.

Now I'm searching for that global variable that has been defined for Reactstrap . Unfortunately, the demo link for using CDN links is broken (I've already opened an issue ).

I searched the web and skimmed through the Reactstrap docs and I can't find anything.

I guessed it would be Reactstrap.X but that doesn't work.

I'm assuming this isn't a new request but I haven't found the answer (or it being asked), so I'd be happy if you can help me out.

For using Reactstrap with CDN you should import stylesheet and Script then use Reactstrap for components.

Example :

 ReactDOM.render(<Reactstrap.Button>ReactStrap</Reactstrap.Button>, document.getElementById("react"));
 <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.8.4/umd/react.production.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.4/umd/react-dom.production.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/reactstrap/4.8.0/reactstrap.min.js" ></script> <link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"> <div id="react"></div>

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