Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
React.Element<any> / React.Element<*> -> React.Node as much as possible
Browse files Browse the repository at this point in the history
Summary:
Most of the time when people annotate something with `React.Element<any>` or `React.Element<*>` they don't really care about it really being a React element, and would be just as happy with `React.Node`. The exceptions I encountered when writing this diff were:

1) places where people do `React.cloneElement` -- in that case we of course need an element
2) components that want some of the props or children to be a certain component type -- but in those cases we ought to specify the type of element rather than accepting `any` or `*`

As such, it's reasonable to replace `React.Element<any>` and `React.Element<*>` if doing so does not cause any Flow errors, and this should put a noticeable dent in our usage of unsafe Flow types.

Reviewed By: camspiers, stryju

Differential Revision: D7810983

fbshipit-source-id: d28f645a63cdfbae74370817e36c5bf590f543d6
  • Loading branch information
miorel authored and facebook-github-bot committed May 8, 2018
1 parent d2a3ae8 commit a1f4593
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/component/base/DraftEditor.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class DraftEditor extends React.Component<DraftEditorProps, State> {
);
}

_renderPlaceholder(): ?React.Element<any> {
_renderPlaceholder(): React.Node {
if (this._showPlaceholder()) {
const placeHolderProps = {
text: nullthrows(this.props.placeholder),
Expand Down
2 changes: 1 addition & 1 deletion src/component/contents/DraftEditorBlock.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class DraftEditorBlock extends React.Component<Props> {
}
}

_renderChildren(): Array<React.Element<any>> {
_renderChildren(): Array<React.Node> {
const block = this.props.block;
const blockKey = block.getKey();
const text = block.getText();
Expand Down
2 changes: 1 addition & 1 deletion src/model/decorators/DraftDecorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type DraftDecorator = {
*/
export type DraftDecoratorComponentProps = {
blockKey: BlockNodeKey,
children?: Array<React.Element<any>>,
children?: Array<React.Node>,
contentState: ContentState,
decoratedText: string,
dir: ?HTMLDir,
Expand Down
2 changes: 1 addition & 1 deletion src/model/immutable/DraftBlockRenderConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

export type DraftBlockRenderConfig = {
element: string,
wrapper?: React$Element<any>,
wrapper?: React.Node,
aliasedElements?: Array<string>,
};

0 comments on commit a1f4593

Please sign in to comment.