mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Adding react-redux
This commit is contained in:
@@ -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> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
+21
-1
@@ -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, {}> { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user