Adding react-redux

This commit is contained in:
tkqubo
2015-09-23 23:15:26 +09:00
parent 6288c788f4
commit 33dbe07ff5
2 changed files with 46 additions and 3 deletions
@@ -1,8 +1,25 @@
/// <reference path="react-redux.d.ts" />
/// <reference path="../react/react.d.ts"/>
/// <reference path="../redux/redux.d.ts" />
import { Component } from 'react';
import { connect } from 'react-redux';
import * as React from 'react';
import { Store } from 'redux';
import { connect, Provider } from 'react-redux';
class MyRootComponent extends Component<any, any> {
}
var store: Store;
React.render(
<Provider store={store}>
{() => <MyRootComponent />}
</Provider>,
document.body
);
function mapStateToProps(state: any): any {
return {
@@ -18,10 +35,16 @@ function mapDispatchToProps(dispatch: any): any {
}
export class Counter extends Component<string, string> {
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(Counter);
@connect(mapStateToProps)
export class Counter2 extends Component<string, string> {
}
+21 -1
View File
@@ -3,6 +3,26 @@
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../react/react.d.ts" />
declare module "react-redux" {
export function connect<T>(...functions: Function[]): (t: T) => T;
import { Component } from 'react';
export interface ClassDecorator {
<TFunction extends Function>(target: TFunction): TFunction|void;
}
export function connect(...functions: Function[]): ClassDecorator;
export interface Store {
subscribe: Function;
dispatch: Function;
getState: Function;
}
export interface Property {
store: Store;
}
export class Provider extends Component<Property, {}> { }
}