Skip to content

Commit 0b03b2b

Browse files
committed
[react] Replace deprecated StatelessComponent in favor of FunctionComponent
1 parent 99e104d commit 0b03b2b

91 files changed

Lines changed: 252 additions & 252 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

types/chai-enzyme/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/// <reference types="cheerio" />
1212

1313
declare namespace Chai {
14-
type EnzymeSelector = string | React.StatelessComponent<any> | React.ComponentClass<any> | { [key: string]: any };
14+
type EnzymeSelector = string | React.FunctionComponent<any> | React.ComponentClass<any> | { [key: string]: any };
1515

1616
interface Match {
1717
/**

types/emoji-mart/dist-es/components/emoji/emoji.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import React = require('react');
22

33
import { EmojiProps } from '../..';
44

5-
declare const Emoji: React.StatelessComponent<EmojiProps>;
5+
declare const Emoji: React.FunctionComponent<EmojiProps>;
66

77
export { Emoji as default };

types/enzyme/enzyme-tests.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
ShallowRendererProps,
1212
ComponentClass as EnzymeComponentClass
1313
} from "enzyme";
14-
import { Component, ReactElement, ReactNode, HTMLAttributes, ComponentClass, StatelessComponent } from "react";
14+
import { Component, ReactElement, ReactNode, HTMLAttributes, ComponentClass, FunctionComponent } from "react";
1515

1616
// Help classes/interfaces
1717
interface MyComponentProps {
@@ -45,7 +45,7 @@ interface MyProviderProps {
4545
value: string;
4646
}
4747

48-
function toComponentType<T>(Component: ComponentClass<T> | StatelessComponent<T>): ComponentClass<T> | StatelessComponent<T> {
48+
function toComponentType<T>(Component: ComponentClass<T> | FunctionComponent<T>): ComponentClass<T> | FunctionComponent<T> {
4949
return Component;
5050
}
5151

@@ -467,7 +467,7 @@ function ShallowWrapperTest() {
467467
}
468468

469469
function test_type() {
470-
const type: string | StatelessComponent<MyComponentProps> | ComponentClass<MyComponentProps> = shallowWrapper.type();
470+
const type: string | FunctionComponent<MyComponentProps> | ComponentClass<MyComponentProps> = shallowWrapper.type();
471471
}
472472

473473
function test_name() {
@@ -904,7 +904,7 @@ function ReactWrapperTest() {
904904
}
905905

906906
function test_type() {
907-
const type: string | StatelessComponent<MyComponentProps> | ComponentClass<MyComponentProps> = reactWrapper.type();
907+
const type: string | FunctionComponent<MyComponentProps> | ComponentClass<MyComponentProps> = reactWrapper.type();
908908
}
909909

910910
function test_name() {

types/enzyme/index.d.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ export type HTMLAttributes = ReactHTMLAttributes<{}> & ReactSVGAttributes<{}>;
2929

3030
export class ElementClass extends Component<any, any> {}
3131

32-
/* These are purposefully stripped down versions of React.ComponentClass and React.StatelessComponent.
32+
/* These are purposefully stripped down versions of React.ComponentClass and React.FunctionComponent.
3333
* The optional static properties on them break overload ordering for wrapper methods if they're not
3434
* all specified in the implementation. TS chooses the EnzymePropSelector overload and loses the generics
3535
*/
3636
export interface ComponentClass<Props> {
3737
new (props: Props, context?: any): Component<Props>;
3838
}
3939

40-
export type StatelessComponent<Props> = (props: Props, context?: any) => JSX.Element | null;
40+
export type FunctionComponent<Props> = (props: Props, context?: any) => JSX.Element | null;
4141

42-
export type ComponentType<Props> = ComponentClass<Props> | StatelessComponent<Props>;
42+
export type ComponentType<Props> = ComponentClass<Props> | FunctionComponent<Props>;
4343

4444
/**
4545
* Many methods in Enzyme's API accept a selector as an argument. Selectors in Enzyme can fall into one of the
@@ -54,7 +54,7 @@ export type ComponentType<Props> = ComponentClass<Props> | StatelessComponent<Pr
5454
export interface EnzymePropSelector {
5555
[key: string]: any;
5656
}
57-
export type EnzymeSelector = string | StatelessComponent<any> | ComponentClass<any> | EnzymePropSelector;
57+
export type EnzymeSelector = string | FunctionComponent<any> | ComponentClass<any> | EnzymePropSelector;
5858

5959
export type Intercepter<T> = (intercepter: T) => void;
6060

@@ -389,7 +389,7 @@ export interface CommonWrapper<P = {}, S = {}, C = Component<P, S>> {
389389
*
390390
* Note: can only be called on a wrapper of a single node.
391391
*/
392-
type(): string | ComponentClass<P> | StatelessComponent<P>;
392+
type(): string | ComponentClass<P> | FunctionComponent<P>;
393393

394394
length: number;
395395
}
@@ -406,7 +406,7 @@ export class ShallowWrapper<P = {}, S = {}, C = Component> {
406406
* Find every node in the render tree that matches the provided selector.
407407
* @param selector The selector to match.
408408
*/
409-
find<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
409+
find<P2>(statelessComponent: FunctionComponent<P2>): ShallowWrapper<P2, never>;
410410
find<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
411411
find<C2 extends Component>(
412412
componentClass: ComponentClass<C2['props']>,
@@ -418,7 +418,7 @@ export class ShallowWrapper<P = {}, S = {}, C = Component> {
418418
* Removes nodes in the current wrapper that do not match the provided selector.
419419
* @param selector The selector to match.
420420
*/
421-
filter<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
421+
filter<P2>(statelessComponent: FunctionComponent<P2>): ShallowWrapper<P2, never>;
422422
filter<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
423423
filter(props: EnzymePropSelector | string): ShallowWrapper<P, S>;
424424

@@ -431,7 +431,7 @@ export class ShallowWrapper<P = {}, S = {}, C = Component> {
431431
* Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector
432432
* can be provided and it will filter the children by this selector.
433433
*/
434-
children<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
434+
children<P2>(statelessComponent: FunctionComponent<P2>): ShallowWrapper<P2, never>;
435435
children<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
436436
children(selector: string): ShallowWrapper<HTMLAttributes, any>;
437437
children(props?: EnzymePropSelector): ShallowWrapper<any, any>;
@@ -466,7 +466,7 @@ export class ShallowWrapper<P = {}, S = {}, C = Component> {
466466
*
467467
* Note: can only be called on a wrapper of a single node.
468468
*/
469-
parents<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
469+
parents<P2>(statelessComponent: FunctionComponent<P2>): ShallowWrapper<P2, never>;
470470
parents<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
471471
parents(selector: string): ShallowWrapper<HTMLAttributes, any>;
472472
parents(props?: EnzymePropSelector): ShallowWrapper<any, any>;
@@ -477,7 +477,7 @@ export class ShallowWrapper<P = {}, S = {}, C = Component> {
477477
*
478478
* Note: can only be called on a wrapper of a single node.
479479
*/
480-
closest<P2>(statelessComponent: StatelessComponent<P2>): ShallowWrapper<P2, never>;
480+
closest<P2>(statelessComponent: FunctionComponent<P2>): ShallowWrapper<P2, never>;
481481
closest<P2>(component: ComponentType<P2>): ShallowWrapper<P2, any>;
482482
closest(props: EnzymePropSelector): ShallowWrapper<any, any>;
483483
closest(selector: string): ShallowWrapper<HTMLAttributes, any>;
@@ -541,7 +541,7 @@ export class ReactWrapper<P = {}, S = {}, C = Component> {
541541
* Find every node in the render tree that matches the provided selector.
542542
* @param selector The selector to match.
543543
*/
544-
find<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
544+
find<P2>(statelessComponent: FunctionComponent<P2>): ReactWrapper<P2, never>;
545545
find<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
546546
find<C2 extends Component>(componentClass: ComponentClass<C2['props']>): ReactWrapper<C2['props'], C2['state'], C2>;
547547
find(props: EnzymePropSelector): ReactWrapper<any, any>;
@@ -556,15 +556,15 @@ export class ReactWrapper<P = {}, S = {}, C = Component> {
556556
* Removes nodes in the current wrapper that do not match the provided selector.
557557
* @param selector The selector to match.
558558
*/
559-
filter<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
559+
filter<P2>(statelessComponent: FunctionComponent<P2>): ReactWrapper<P2, never>;
560560
filter<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
561561
filter(props: EnzymePropSelector | string): ReactWrapper<P, S>;
562562

563563
/**
564564
* Returns a new wrapper with all of the children of the node(s) in the current wrapper. Optionally, a selector
565565
* can be provided and it will filter the children by this selector.
566566
*/
567-
children<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
567+
children<P2>(statelessComponent: FunctionComponent<P2>): ReactWrapper<P2, never>;
568568
children<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
569569
children(selector: string): ReactWrapper<HTMLAttributes, any>;
570570
children(props?: EnzymePropSelector): ReactWrapper<any, any>;
@@ -581,7 +581,7 @@ export class ReactWrapper<P = {}, S = {}, C = Component> {
581581
*
582582
* Note: can only be called on a wrapper of a single node.
583583
*/
584-
parents<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
584+
parents<P2>(statelessComponent: FunctionComponent<P2>): ReactWrapper<P2, never>;
585585
parents<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
586586
parents(selector: string): ReactWrapper<HTMLAttributes, any>;
587587
parents(props?: EnzymePropSelector): ReactWrapper<any, any>;
@@ -592,7 +592,7 @@ export class ReactWrapper<P = {}, S = {}, C = Component> {
592592
*
593593
* Note: can only be called on a wrapper of a single node.
594594
*/
595-
closest<P2>(statelessComponent: StatelessComponent<P2>): ReactWrapper<P2, never>;
595+
closest<P2>(statelessComponent: FunctionComponent<P2>): ReactWrapper<P2, never>;
596596
closest<P2>(component: ComponentType<P2>): ReactWrapper<P2, any>;
597597
closest(props: EnzymePropSelector): ReactWrapper<any, any>;
598598
closest(selector: string): ReactWrapper<HTMLAttributes, any>;

types/flux/lib/FluxContainer.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface RealOptions {
2020
withContext?: boolean | undefined;
2121
}
2222

23-
export type ComponentConstructor<TProps> = React.ComponentClass<TProps> | React.StatelessComponent<TProps>;
23+
export type ComponentConstructor<TProps> = React.ComponentClass<TProps> | React.FunctionComponent<TProps>;
2424

2525
export type StoresList = Array<FluxStore<any>>;
2626

types/material-ui/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ declare namespace __MaterialUI {
516516
let darkBaseTheme: RawTheme;
517517

518518
export function muiThemeable(): <
519-
TComponent extends React.ComponentClass<P> | React.StatelessComponent<P>,
519+
TComponent extends React.ComponentClass<P> | React.FunctionComponent<P>,
520520
P extends {muiTheme?: MuiTheme | undefined}
521521
>(component: TComponent) => TComponent;
522522

types/material-ui/material-ui-tests.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import {
33
Component, ComponentClass, CSSProperties,
4-
StatelessComponent, ReactElement, ReactInstance, ValidationMap
4+
FunctionComponent, ReactElement, ReactInstance, ValidationMap
55
} from 'react';
66
import * as ReactDOM from 'react-dom';
77
import * as PropTypes from 'prop-types';
@@ -2288,7 +2288,7 @@ interface Props {
22882288
label: string;
22892289
muiTheme?: MuiTheme | undefined;
22902290
}
2291-
const MuiThemeableFunction = muiThemeable()<StatelessComponent<Props>, Props>(props => {
2291+
const MuiThemeableFunction = muiThemeable()<FunctionComponent<Props>, Props>(props => {
22922292
return (
22932293
<span style={{color: props.muiTheme.palette.textColor}}>
22942294
Applied the Theme to functional component: {props.label}.

types/react-adal/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ export function withAdalLogin(
383383
authContext: AuthenticationContext,
384384
resource: string,
385385
): (
386-
wrappedComponent: React.ComponentClass | React.StatelessComponent,
386+
wrappedComponent: React.ComponentClass | React.FunctionComponent,
387387
renderLoading: () => JSX.Element | null,
388388
renderError: (error: any) => JSX.Element | null,
389389
) => React.ComponentClass;

types/react-aria-live/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ export class LiveAnnouncer extends React.Component {
1111
announceAssertive(message: string, id?: string): void;
1212
}
1313

14-
export const LiveMessage: React.StatelessComponent<{
14+
export const LiveMessage: React.FunctionComponent<{
1515
'aria-live': 'assertive' | 'polite';
1616
clearOnUnmount?: boolean | 'true' | 'false' | undefined;
1717
message: string;
1818
}>;
1919

20-
export const LiveMessenger: React.StatelessComponent<{
20+
export const LiveMessenger: React.FunctionComponent<{
2121
children(contextProps: {
2222
announceAssertive(message: string, id?: string): void;
2323
announcePolite(message: string, id?: string): void;

types/react-bootstrap-date-picker/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
55
// TypeScript Version: 2.8
66

7-
import { ComponentClass, StatelessComponent, ReactNode, FocusEventHandler, HTMLAttributes } from "react";
7+
import { ComponentClass, FunctionComponent, ReactNode, FocusEventHandler, HTMLAttributes } from "react";
88

99
export as namespace DatePicker;
1010

@@ -42,6 +42,6 @@ declare namespace DatePicker {
4242
weekStartsOnMonday?: boolean | undefined;
4343
showTodayButton?: boolean | undefined;
4444
todayButtonLabel?: string | undefined;
45-
customControl?: StatelessComponent<any> | ComponentClass<any> | undefined;
45+
customControl?: FunctionComponent<any> | ComponentClass<any> | undefined;
4646
}
4747
}

0 commit comments

Comments
 (0)