icestark
Icestark is a JavaScript library for multiple react projects, Ice workbench solution.
Installation
npm install icestark --save
Example
import React from 'react';
import ReactDOM from 'react-dom';
import { AppRouter, AppRoute } from 'icestark';
class Layout extends React.Component {
onRouteChange = (pathname, query) => {
console.log(pathname, query);
}
render() {
return (
<div>
<div>this is common header</div>
<AppRouter
onRouteChange={this.onRouteChange}
useShadow
>
<AppRoute
path={['/', '/home', '/about']}
exact
title="主页"
url={['//127.0.0.1:4444/js/index.js', '//127.0.0.1:4444/css/index.css']}
/>
<AppRoute
path="/user"
title="用户页面"
url={['//127.0.0.1:5555/js/index.js', '//127.0.0.1:5555/css/index.css']}
/>
</AppRouter>
<div>this is common footer</div>
</div>
);
}
}
Configuration
AppRouter
Property | Description | Type | Default |
---|
onRouteChange | callback executed when route changed | function | noop |
NotFoundComponent | render when the route changed error | ReactElement | |
BundleErrorComponent | render when the bundle pulls an error | ReactElement | |
BundleLoadingComponent | render when Bundle is Loading | ReactElement | |
shadowRoot | whether to use shadowRoot | boolean | false |
AppRoute
Property | Description | Type | Default |
---|
path | app router path, reference react-router, required | string/string[] | |
url | assets load url, required | string/string[] | |
title | documentTitle | string | |
exact | reference react-router | boolean | false |
strict | reference react-router | boolean | false |
sensitive | reference react-router | boolean | false |