feat(react-dock): allow ReactNode children in types (#610)

This commit is contained in:
Nathan Bierema 2020-08-26 08:54:44 -04:00 committed by GitHub
parent 78ded9e0ca
commit 9000e369cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 9 deletions

View File

@ -31,7 +31,7 @@
"build": "npm run build:types && npm run build:js",
"build:types": "tsc --emitDeclarationOnly",
"build:js": "babel src --out-dir lib --extensions \".ts,.tsx\" --source-maps inline",
"clean": "rimraf lib umd",
"clean": "rimraf lib",
"test": "jest",
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "eslint . --ext .ts,.tsx --fix",

View File

@ -1,4 +1,4 @@
import React, { Component } from 'react';
import React, { Component, ReactNode } from 'react';
import PropTypes from 'prop-types';
import debounce from 'lodash.debounce';
import autoprefix from './autoprefix';
@ -227,12 +227,14 @@ interface Props {
dockStyle?: React.CSSProperties | null;
dockHiddenStyle?: React.CSSProperties | null;
duration: number;
children?: React.FunctionComponent<{
children?:
| React.FunctionComponent<{
position: 'left' | 'right' | 'top' | 'bottom';
isResizing: boolean | undefined;
size: number;
isVisible: boolean | undefined;
}>;
}>
| ReactNode;
}
interface State {
@ -376,7 +378,12 @@ export default class Dock extends Component<Props, State> {
/>
<div style={styles.dockContent}>
{typeof children === 'function'
? children({
? (children as React.FunctionComponent<{
position: 'left' | 'right' | 'top' | 'bottom';
isResizing: boolean | undefined;
size: number;
isVisible: boolean | undefined;
}>)({
position,
isResizing,
size,