Skip to content

Commit

Permalink
fix(react): Fix warning about access to PropTypes using React 15.5+ (f…
Browse files Browse the repository at this point in the history
…ixes #213)

Explicit import of React's types to avoid star import that leads to warning about access to PropTypes (fixes #213).
  • Loading branch information
lahmatiy authored and armandabric committed Oct 30, 2017
1 parent 0db5aa4 commit 2dcfd10
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* @flow */

import * as React from 'react';
import formatTree from './formatter/formatTree';
import parseReactElement from './parser/parseReactElement';
import type { Element as ReactElement } from 'react';
import type { Options } from './options';

const reactElementToJsxString = (
element: React.Element<any>,
element: ReactElement<any>,
{
filterProps = [],
showDefaultProps = true,
Expand Down
6 changes: 3 additions & 3 deletions src/parser/parseReactElement.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @flow */

import * as React from 'react';
import React, { type Element as ReactElement } from 'react';
import type { Options } from './../options';
import {
createStringTreeNode,
Expand All @@ -9,7 +9,7 @@ import {
} from './../tree';
import type { TreeNode } from './../tree';

const getReactElementDisplayName = (element: React.Element<*>): string =>
const getReactElementDisplayName = (element: ReactElement<*>): string =>
element.type.displayName ||
element.type.name || // function name
(typeof element.type === 'function' // function without a name, you should provide one
Expand All @@ -35,7 +35,7 @@ const filterProps = (originalProps: {}, cb: (any, string) => boolean) => {
};

const parseReactElement = (
element: React.Element<*> | string | number,
element: ReactElement<*> | string | number,
options: Options
): TreeNode => {
const { displayName: displayNameFn = getReactElementDisplayName } = options;
Expand Down

0 comments on commit 2dcfd10

Please sign in to comment.