Skip to content

Commit f725230

Browse files
committed
feat: 🎸 add universal component typings
1 parent 392214e commit f725230

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

‎src/SyncSensor/index.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import * as React from 'react';
22
import {noop} from '../util';
33
import renderProp from '../util/renderProp';
44
import {throttle} from 'throttle-debounce';
5+
import {IUniversalInterfaceProps} from '../typing';
56

6-
export interface ISyncSensorProps<TState> {
7+
export interface ISyncSensorProps<TState> extends IUniversalInterfaceProps<TState> {
78
throttle?: number;
89
initial?: TState;
9-
children?: (state: TState) => React.ReactElement<any>;
1010
addListener: (handler) => void;
1111
removeListener: (handler) => void;
1212
onChange: (state: TState) => void;

‎src/WindowSizeSensor/index.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import {Component} from 'react';
22
import {SyncSensor} from '../SyncSensor';
33
import {isClient, h} from '../util';
44
import faccToHoc from '../util/faccToHoc';
5+
import {IUniversalInterfaceProps} from '../typing';
56

67
export interface IWindowSizeSensorValue {
78
width: number;
89
height: number;
910
}
1011

11-
export interface IWindowSizeSensorProps {
12-
children?: (state: IWindowSizeSensorValue) => React.ReactElement<any>;
12+
export interface IWindowSizeSensorProps extends IUniversalInterfaceProps<IWindowSizeSensorValue> {
1313
onChange?: (state: IWindowSizeSensorValue) => void;
1414
}
1515

@@ -36,11 +36,10 @@ export class WindowSizeSensor extends Component<IWindowSizeSensorProps, any> {
3636

3737
render () {
3838
return h(SyncSensor, {
39-
children: this.props.children,
39+
...this.props,
4040
initial: this.initial,
4141
addListener,
4242
removeListener,
43-
onChange: this.props.onChange,
4443
onEvent
4544
});
4645
}

0 commit comments

Comments
 (0)