Skip to content

Commit cb5b75b

Browse files
committed
Remove more defaultProps
1 parent ac3776c commit cb5b75b

File tree

9 files changed

+9
-39
lines changed

9 files changed

+9
-39
lines changed

@plotly/dash-generator-test-component-nested/src/components/MyNestedComponent.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from 'react';
44
/**
55
* MyNestedComponent description
66
*/
7-
const MyNestedComponent = ({ id, value }) => (<div id={id}>{value}</div>);
7+
const MyNestedComponent = ({ id, value = '' }) => (<div id={id}>{value}</div>);
88

99
MyNestedComponent.propTypes = {
1010
/**
@@ -18,8 +18,4 @@ MyNestedComponent.propTypes = {
1818
value: PropTypes.string
1919
};
2020

21-
MyNestedComponent.defaultProps = {
22-
value: ''
23-
};
24-
2521
export default MyNestedComponent;

@plotly/dash-generator-test-component-standard/src/components/MyStandardComponent.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from 'react';
44
/**
55
* MyComponent description
66
*/
7-
const MyStandardComponent = ({ id, style, value }) => (<div id={id} style={style}>{value}</div>);
7+
const MyStandardComponent = ({ id, style, value = '' }) => (<div id={id} style={style}>{value}</div>);
88

99
MyStandardComponent.propTypes = {
1010
/**
@@ -23,8 +23,4 @@ MyStandardComponent.propTypes = {
2323
value: PropTypes.string
2424
};
2525

26-
MyStandardComponent.defaultProps = {
27-
value: ''
28-
};
29-
30-
export default MyStandardComponent;
26+
export default MyStandardComponent;

@plotly/dash-test-components/src/components/AsyncComponent.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,4 @@ AsyncComponent.propTypes = {
1414
value: PropTypes.string
1515
};
1616

17-
AsyncComponent.defaultProps = {};
18-
1917
export default AsyncComponent;

@plotly/dash-test-components/src/components/CollapseComponent.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,4 @@ CollapseComponent.propTypes = {
1111
id: PropTypes.string
1212
};
1313

14-
CollapseComponent.defaultProps = {
15-
display: false
16-
};
17-
1814
export default CollapseComponent;
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
33

4-
const DelayedEventComponent = ({ id, n_clicks, setProps }) => (<button
4+
const DelayedEventComponent = ({ id, n_clicks = 0, setProps }) => (<button
55
id={id}
66
onClick={() => setTimeout(() => setProps({ n_clicks: n_clicks + 1 }), 20)}
77
/>);
@@ -11,8 +11,4 @@ DelayedEventComponent.propTypes = {
1111
n_clicks: PropTypes.number
1212
};
1313

14-
DelayedEventComponent.defaultProps = {
15-
n_clicks: 0
16-
};
17-
1814
export default DelayedEventComponent;

@plotly/dash-test-components/src/components/FragmentComponent.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,4 @@ FragmentComponent.propTypes = {
1010
id: PropTypes.string
1111
};
1212

13-
FragmentComponent.defaultProps = {};
14-
15-
export default FragmentComponent;
13+
export default FragmentComponent;

@plotly/dash-test-components/src/components/StyledComponent.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from 'react';
44
/**
55
* MyComponent description
66
*/
7-
const StyledComponent = ({ id, style, value }) => (<div id={id} style={style}>{value}</div>);
7+
const StyledComponent = ({ id, style, value = '' }) => (<div id={id} style={style}>{value}</div>);
88

99
StyledComponent.propTypes = {
1010
/**
@@ -23,8 +23,4 @@ StyledComponent.propTypes = {
2323
value: PropTypes.string
2424
};
2525

26-
StyledComponent.defaultProps = {
27-
value: ''
28-
};
29-
3026
export default StyledComponent;
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import PropTypes from 'prop-types';
22
import React, { Fragment } from 'react';
33

4-
const WidthComponent = props => (<Fragment>
5-
{props.width}
4+
const WidthComponent = ({width = 0}) => (<Fragment>
5+
{width}
66
</Fragment>);
77

88
WidthComponent.propTypes = {
99
id: PropTypes.string,
1010
width: PropTypes.number
1111
};
1212

13-
WidthComponent.defaultProps = {
14-
width: 0
15-
};
16-
17-
export default WidthComponent;
13+
export default WidthComponent;

@plotly/dash-test-components/src/fragments/AsyncComponent.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,4 @@ AsyncComponent.propTypes = {
1111
value: PropTypes.string
1212
};
1313

14-
AsyncComponent.defaultProps = {};
15-
1614
export default AsyncComponent;

0 commit comments

Comments
 (0)