mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge branch 'react-v14' of github.com:jbrantly/DefinitelyTyped into react-v14
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
// Type definitions for React v0.14 (react-addons-css-transition-group)
|
||||
// Project: http://facebook.github.io/react/
|
||||
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="react.d.ts" />
|
||||
|
||||
declare module "react-addons-shallow-compare" {
|
||||
function shallowCompare<P, S>(component: __React.Component<P, S>, nextProps: P, nextState: S): boolean;
|
||||
export = shallowCompare;
|
||||
}
|
||||
+16
-10
@@ -5,6 +5,7 @@
|
||||
/// <reference path="react-addons-linked-state-mixin.d.ts" />
|
||||
/// <reference path="react-addons-perf.d.ts" />
|
||||
/// <reference path="react-addons-pure-render-mixin.d.ts" />
|
||||
/// <reference path="react-addons-shallow-compare.d.ts" />
|
||||
/// <reference path="react-addons-test-utils.d.ts" />
|
||||
/// <reference path="react-addons-transition-group.d.ts" />
|
||||
/// <reference path="react-addons-update.d.ts" />
|
||||
@@ -16,6 +17,7 @@ import CSSTransitionGroup = require("react-addons-css-transition-group");
|
||||
import LinkedStateMixin = require("react-addons-linked-state-mixin");
|
||||
import Perf = require("react-addons-perf");
|
||||
import PureRenderMixin = require("react-addons-pure-render-mixin");
|
||||
import shallowCompare = require("react-addons-shallow-compare");
|
||||
import TestUtils = require("react-addons-test-utils");
|
||||
import TransitionGroup = require("react-addons-transition-group");
|
||||
import update = require("react-addons-update");
|
||||
@@ -85,32 +87,32 @@ var ClassicComponent: React.ClassicComponentClass<Props> =
|
||||
|
||||
class ModernComponent extends React.Component<Props, State>
|
||||
implements MyComponent, React.ChildContextProvider<ChildContext> {
|
||||
|
||||
|
||||
static propTypes: React.ValidationMap<Props> = {
|
||||
foo: React.PropTypes.number
|
||||
}
|
||||
|
||||
|
||||
static contextTypes: React.ValidationMap<Context> = {
|
||||
someValue: React.PropTypes.string
|
||||
}
|
||||
|
||||
|
||||
static childContextTypes: React.ValidationMap<ChildContext> = {
|
||||
someOtherValue: React.PropTypes.string
|
||||
}
|
||||
|
||||
|
||||
context: Context;
|
||||
|
||||
|
||||
getChildContext() {
|
||||
return {
|
||||
someOtherValue: 'foo'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
state = {
|
||||
inputValue: this.context.someValue,
|
||||
seconds: this.props.foo
|
||||
}
|
||||
|
||||
|
||||
reset() {
|
||||
this._myComponent.reset();
|
||||
this.setState({
|
||||
@@ -121,7 +123,7 @@ class ModernComponent extends React.Component<Props, State>
|
||||
|
||||
private _myComponent: MyComponent;
|
||||
private _input: HTMLInputElement;
|
||||
|
||||
|
||||
render() {
|
||||
return React.DOM.div(null,
|
||||
React.DOM.input({
|
||||
@@ -129,6 +131,10 @@ class ModernComponent extends React.Component<Props, State>
|
||||
value: this.state.inputValue
|
||||
}));
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps: Props, nextState: State, nextContext: any): boolean {
|
||||
return shallowCompare(this, nextProps, nextState);
|
||||
}
|
||||
}
|
||||
|
||||
interface SCProps extends React.Props<{}> {
|
||||
@@ -496,7 +502,7 @@ var renderer: React.ShallowRenderer =
|
||||
renderer.render(React.createElement(Timer));
|
||||
var output: React.ReactElement<React.Props<Timer>> =
|
||||
renderer.getRenderOutput();
|
||||
|
||||
|
||||
//
|
||||
// TransitionGroup addon
|
||||
// --------------------------------------------------------------------------
|
||||
@@ -506,7 +512,7 @@ React.createFactory(TransitionGroup)({ component: "div" });
|
||||
// update addon
|
||||
// --------------------------------------------------------------------------
|
||||
{
|
||||
// These are copied from https://facebook.github.io/react/docs/update.html
|
||||
// These are copied from https://facebook.github.io/react/docs/update.html
|
||||
let initialArray = [1, 2, 3];
|
||||
let newArray = update(initialArray, {$push: [4]}); // => [1, 2, 3, 4]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user