tigajs
v0.0.9
Published
A react-like libray, integration react-router, redux, create model base on redux
Downloads
3
Readme
Installation
npm install tigajs
Basic Used
import TIGA from "tigajs";
const App = () => {
return <p>Hello, Tiga</p>
};
TIGA.render(<App/>, document.getElementById('root'));
Router
import TIGA, {Route, Switch, HashRouter} from "tigajs";
const element = (<HashRouter>
<Switch>
<Route path='/a' component={<p>Is A!</p>}/>
<Route path='/' exact component={<div>Is index!</div>}/>
</Switch>
</HashRouter>);
TIGA.render(element, document.getElementById('root'));
Use Redux base on Model
app.js
import TIGA, {Route, Switch, HashRouter, createModel, modelStart} from "tigajs";
import global from './model/global.js';
import Welcome from './Welcome.js';
createModel(global);
modelStart(
<Welcome/>,
'root'
);
/model/global.js
export default {
namespace: 'global',
state: {
content: 'Hello'
},
epics: {
},
reducers: {
goodbye(state, action) {
return {
...state,
content: 'goodbye'
};
}
}
}
Welcome.js
import TIGA, {Component, withRouterConnectModel} from "tigajs";
class Welcome extends Component {
constructor(props) {
super(props);
}
onClick() {
this.props.dispatch({
type: 'global/goodbye'
})
}
render() {
return (
<button onClick={() => this.onClick()}>back</button>
);
}
}
export default withRouterConnectModel(Welcome, 'global');
redux store storage
createModel(global, true);
config babel
use babel-plugin-transform-tiga-jsx
Tiga is inspired by the following projects:
- react
- react-router
- redux
- react-redux