本文整理汇总了TypeScript中prop-types.shape函数的典型用法代码示例。如果您正苦于以下问题:TypeScript shape函数的具体用法?TypeScript shape怎么用?TypeScript shape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shape函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
/**
* watching is an ES2017 decorator that lets components subscribe
* to actions, much like reactors. They have to define a `subscribe`
* method that will get a watcher as only argument.
*/
export default function(constructor: Function) {
if (!constructor.prototype.subscribe) {
throw new Error(
`Component ${
constructor.name
} is missing subscribe method (watching decorator)`
);
}
const origContextTypes = (constructor as any).contextTypes || {};
(constructor as any).contextTypes = {
...origContextTypes,
store: PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired,
}),
};
const originalWillMount = constructor.prototype.componentWillMount;
constructor.prototype.componentWillMount = function() {
if (!this.context.store) {
throw new Error(
`Can't set up watching because no ` +
`store in context. Did you forget to wrap your top-level component in <Provider/> ?`
);
}
this.watcher = new Watcher();
this.context.store.watcher.addSub(this.watcher);
constructor.prototype.subscribe.call(this, this.watcher);
if (originalWillMount) {
originalWillMount.call(this);
}
};
const originalWillUnmount = constructor.prototype.componentWillUnmount;
constructor.prototype.componentWillUnmount = function() {
if (!this.context.store) {
throw new Error(
`Can't tear down watching because no ` +
`store in context. Did you forget to wrap your top-level component in <Provider/> ?`
);
}
this.context.store.watcher.removeSub(this.watcher);
this.watcher = null;
if (originalWillUnmount) {
originalWillUnmount.call(this);
}
};
}
开发者ID:HorrerGames,项目名称:itch,代码行数:59,代码来源:watching.ts
示例2:
/* globals Element */
import * as PropTypes from 'prop-types';
/** @internal */
export const RefType = PropTypes.shape({
current: PropTypes.instanceOf((typeof Element !== 'undefined') ? Element : Object),
});
开发者ID:MaksimMakarevich,项目名称:devextreme-reactive,代码行数:7,代码来源:ref-type.ts
示例3:
'900'
]),
/**
* @platform ios
*/
fontVariant: ReactPropTypes.arrayOf(
ReactPropTypes.oneOf([
'small-caps',
'oldstyle-nums',
'lining-nums',
'tabular-nums',
'proportional-nums'
])
),
textShadowOffset: ReactPropTypes.shape({
width: ReactPropTypes.number,
height: ReactPropTypes.number
}),
textShadowRadius: ReactPropTypes.number,
textShadowColor: ColorPropType,
/**
* @platform ios
*/
letterSpacing: ReactPropTypes.number,
lineHeight: ReactPropTypes.number,
/**
* Specifies text alignment. The value 'justify' is only supported on iOS and
* fallbacks to `left` on Android.
*/
textAlign: ReactPropTypes.oneOf([
'auto' /* default */,
'left',
开发者ID:YangShaoQun,项目名称:taro,代码行数:32,代码来源:TextStylePropTypes.ts
示例4:
* transformation. Objects should not be combined. Use a single key/value pair
* per object.
*
* The rotate transformations require a string so that the transform may be
* expressed in degrees (deg) or radians (rad). For example:
*
* `transform([{ rotateX: '45deg' }, { rotateZ: '0.785398rad' }])`
*
* The skew transformations require a string so that the transform may be
* expressed in degrees (deg). For example:
*
* `transform([{ skewX: '45deg' }])`
*/
transform: ReactPropTypes.arrayOf(
ReactPropTypes.oneOfType([
ReactPropTypes.shape({perspective: ReactPropTypes.number}),
ReactPropTypes.shape({rotate: ReactPropTypes.string}),
ReactPropTypes.shape({rotateX: ReactPropTypes.string}),
ReactPropTypes.shape({rotateY: ReactPropTypes.string}),
ReactPropTypes.shape({rotateZ: ReactPropTypes.string}),
ReactPropTypes.shape({scale: ReactPropTypes.number}),
ReactPropTypes.shape({scaleX: ReactPropTypes.number}),
ReactPropTypes.shape({scaleY: ReactPropTypes.number}),
ReactPropTypes.shape({translateX: ReactPropTypes.number}),
ReactPropTypes.shape({translateY: ReactPropTypes.number}),
ReactPropTypes.shape({skewX: ReactPropTypes.string}),
ReactPropTypes.shape({skewY: ReactPropTypes.string})
])
),
/**
开发者ID:YangShaoQun,项目名称:taro,代码行数:31,代码来源:TransformPropTypes.ts
示例5: function
import { Watcher } from "common/util/watcher";
export { Watcher } from "common/util/watcher";
import PropTypes from "prop-types";
import { rendererLogger } from "renderer/logger";
export const storeShape = PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired,
});
/**
* watching is an ES2017 decorator that lets components subscribe
* to actions, much like reactors. They have to define a `subscribe`
* method that will get a watcher as only argument.
*/
export default function(constructor: Function) {
if (!constructor.prototype.subscribe) {
throw new Error(
`Component ${
constructor.name
} is missing subscribe method (watching decorator)`
);
}
const origContextTypes = (constructor as any).contextTypes || {};
(constructor as any).contextTypes = {
...origContextTypes,
store: storeShape,
};
开发者ID:itchio,项目名称:itch,代码行数:31,代码来源:watching.ts
示例6: SingleChildShape
});
parentSchema
.morphTo({
Single: singleChildSchema,
'Model::Multiple': multipleChildrenSchema,
}, 'polymorph', '_type', '_fk')
.belongsToMany({
children: multipleChildrenSchema,
})
.hasOne({
orphan: singleChildSchema,
});
export const MultipleChildrenShape = PropTypes.shape({
uuid: PropTypes.string,
});
export interface MultipleChildrenShape {
uuid?: string;
}
export const SingleChildShape = PropTypes.shape({
id: PropTypes.number,
active: PropTypes.bool,
self: (...args) => SingleChildShape(...args),
});
export interface SingleChildShape {
id?: number;
active?: boolean;
开发者ID:milesj,项目名称:shapeshifter,代码行数:31,代码来源:infer-and-schema-generics.ts
示例7: emit
import Emitter from '@devexperts/utils/dist/emitter/Emitter';
import * as PropTypes from 'prop-types';
export const EVENT_SCROLABLE = {
RESIZE: 'EVENT_SCROLABLE:RESIZE',
SCROLL: 'EVENT_SCROLLABLE:SROLL',
SCROLLBAR_UPDATE: 'EVENT_SCROLABLE:SCROLLBAR_UPDATE',
};
export class ScrollableInternalEmitter extends Emitter {
emit(event: any, ...args: any[]) {
this._emit(event, ...args);
}
}
export const SCROLLABLE_CONTEXT_EMITTER = '__SCROLLABLE__CONTEXT_EMITTER__';
export const CONTEXT_TYPES = {
[SCROLLABLE_CONTEXT_EMITTER.toString()]: PropTypes.instanceOf(ScrollableInternalEmitter).isRequired,
size: PropTypes.shape({
width: PropTypes.number,
height: PropTypes.number,
}),
};
开发者ID:sutarmin,项目名称:dx-platform,代码行数:23,代码来源:Scrollable.const.ts
示例8:
foo: string;
bar?: boolean;
baz?: any
};
optionalNumber?: number | null;
customProp?: typeof uniqueType;
}
const innerProps = {
foo: PropTypes.string.isRequired,
bar: PropTypes.bool,
baz: PropTypes.any
};
const arrayOfTypes = [PropTypes.string, PropTypes.bool, PropTypes.shape({
foo: PropTypes.string,
bar: PropTypes.number.isRequired
})];
type PropTypesMap = PropTypes.ValidationMap<Props>;
// TS checking
const propTypes: PropTypesMap = {
any: PropTypes.any,
array: PropTypes.array.isRequired,
bool: PropTypes.bool.isRequired,
element: PropTypes.element.isRequired,
func: PropTypes.func.isRequired,
node: PropTypes.node,
requiredNode: PropTypes.node.isRequired,
number: PropTypes.number.isRequired,
object: PropTypes.object.isRequired,
string: PropTypes.string.isRequired,
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:32,代码来源:prop-types-tests.ts
示例9:
import * as PropTypes from 'prop-types';
export const SomeShape = PropTypes.shape({});
开发者ID:vcarrera,项目名称:react-docgen-typescript,代码行数:3,代码来源:shapes.ts
示例10:
import * as PropTypes from 'prop-types'
export default PropTypes.shape({
subscribe: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired,
getFormState: PropTypes.func.isRequired,
setFormState: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
addValidator: PropTypes.func.isRequired,
removeValidator: PropTypes.func.isRequired,
addSubmitListener: PropTypes.func.isRequired,
removeSubmitListener: PropTypes.func.isRequired,
validate: PropTypes.func.isRequired,
submit: PropTypes.func.isRequired,
setValue: PropTypes.func.isRequired,
setValidationError: PropTypes.func.isRequired,
clearValidationError: PropTypes.func.isRequired,
reset: PropTypes.func.isRequired,
clear: PropTypes.func.isRequired,
unsubscribe: PropTypes.func.isRequired
})
开发者ID:jschr,项目名称:react-redux-local-form,代码行数:21,代码来源:formStoreShape.ts
注:本文中的prop-types.shape函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论