React JSPort
npm install react-jsport
DEMO
https://means88.github.io/react-jsport/
INTERFACE
;/** * @param requirements: array of url[dfault=[]] * @param options object[default={}]: { * force: boolean[default=false], requirements with the same url will not be loaded twice by default * loadingElement: ReactElement[default=null], be rendered while loading * errorElement: ReactElement[default=null], be rendered when an error caused * } * @return ReactComponent */ JSPort.propTypes = { // requirements, can be url or list of url require: PropTypes // load requirements even if it has been loaded force: PropTypesbool children: PropTypes loadingElement: PropTypeselement errorElement: PropTypeselement}; JSPortdefaultProps = require: force: false children: null loadingElement: null errorElement: null; Component;// ==><JSPort requirements=requirements ...options> <Component /></JSPort>
USAGE
; Component = Component; // or @Component // ...
Or wrapped in JSPort
Component { this; } { this; } { text'Changed by jQuery'; } { return <a id="hello" className="btn btn-default"> Hello world </a> ; } // import jQuery dynamically; <JSPort require= "https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js" "https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" > <Component /></JSPort>
TODO
- cache