Skip to content

Commit fa7d30a

Browse files
authored
Merge pull request #2926 from AnnMarieW/fix-defaultProps
Update default props
2 parents 0d9cd2c + 94354c0 commit fa7d30a

File tree

17 files changed

+282
-77
lines changed

17 files changed

+282
-77
lines changed

@plotly/dash-generator-test-component-typescript/src/components/TypeScriptComponent.tsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,17 @@ import {TypescriptComponentProps} from '../props';
44
/**
55
* Component docstring
66
*/
7-
const TypeScriptComponent = (props: TypescriptComponentProps) => {
8-
const {required_string, id} = props;
9-
return <div id={id}>{required_string}</div>;
10-
};
11-
12-
TypeScriptComponent.defaultProps = {
13-
string_default: 'default',
14-
number_default: 42,
15-
bool_default: true,
16-
null_default: null,
17-
obj_default: {
18-
a: 'a',
19-
b: 3
20-
}
7+
const TypeScriptComponent = ({
8+
required_string,
9+
id,
10+
string_default = 'default',
11+
number_default = 42,
12+
bool_default = true,
13+
null_default = null,
14+
obj_default = { a: 'a', b: 3 },
15+
...props
16+
}: TypescriptComponentProps) => {
17+
return <div id={id}>{required_string}</div>;
2118
};
2219

2320
export default TypeScriptComponent;

@plotly/dash-generator-test-component-typescript/src/props.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export type TypescriptComponentProps = {
3232
array_elements?: JSX.Element[];
3333

3434
string_default?: string;
35-
number_default?: string;
35+
number_default?: number;
3636
obj_default?: {a: string; b: number};
3737
bool_default?: boolean;
3838
null_default?: any;

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1313
- [#3025](https://github.com/plotly/dash/pull/3025) Fix no output callback with error handler setting the response to NoUpdate and triggering an error.
1414
- [#3034](https://github.com/plotly/dash/pull/3034) Remove whitespace from `metadata.json` files to reduce package size.
1515
- [#3009](https://github.com/plotly/dash/pull/3009) Performance improvement on (pattern-matching) callbacks.
16-
- [3028](https://github.com/plotly/dash/pull/3028) Fix jupyterlab v4 support.
16+
- [#3028](https://github.com/plotly/dash/pull/3028) Fix jupyterlab v4 support.
17+
- [#2926](https://github.com/plotly/dash/pull/2926) Fix components defaultProps with react 18.3.1
1718
- [#3051](https://github.com/plotly/dash/pull/3051) Add missing request data to callback context. Fix [#2235](https://github.com/plotly/dash/issues/2235).
1819

1920
## [2.18.1] - 2024-09-12

components/dash-core-components/.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"react",
3030
"import"
3131
],
32+
"parser": "@babel/eslint-parser",
3233
"rules": {
3334
"accessor-pairs": ["error"],
3435
"block-scoped-var": ["error"],
@@ -43,7 +44,7 @@
4344
"import/named": ["off"],
4445
"import/namespace": ["off"],
4546
"import/no-duplicates": ["error"],
46-
"import/no-named-as-default": ["error"],
47+
"import/no-named-as-default": ["off"],
4748
"import/no-unresolved": ["off"],
4849
"new-cap": ["error", {
4950
"capIsNewExceptionPattern": "Immutable\\.*"

components/dash-core-components/package-lock.json

Lines changed: 105 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/dash-core-components/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"devDependencies": {
6767
"@babel/cli": "^7.25.7",
6868
"@babel/core": "^7.25.8",
69+
"@babel/eslint-parser": "^7.25.8",
6970
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
7071
"@babel/preset-env": "^7.25.8",
7172
"@babel/preset-react": "^7.25.7",

components/dash-core-components/src/components/Link.react.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ CustomEvent.prototype = window.Event.prototype;
3232
* For links with destinations outside the current app, `html.A` is a better
3333
* component to use.
3434
*/
35-
const Link = props => {
35+
const Link = ({refresh = false, ...props}) => {
3636
const {
3737
className,
3838
style,
@@ -42,7 +42,6 @@ const Link = props => {
4242
children,
4343
title,
4444
target,
45-
refresh,
4645
setProps,
4746
} = props;
4847
const cleanUrl = window.dash_clientside.clean_url;
@@ -155,7 +154,4 @@ Link.propTypes = {
155154
setProps: PropTypes.func,
156155
};
157156

158-
Link.defaultProps = {
159-
refresh: false,
160-
};
161157
export default Link;

components/dash-core-components/src/components/Loading.react.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const getSpinner = spinnerType =>
2222
const Loading = ({
2323
children,
2424
loading_state,
25-
display,
26-
color,
25+
display = 'auto',
26+
color = '#119DFF',
2727
id,
2828
className,
2929
style,
@@ -32,10 +32,10 @@ const Loading = ({
3232
overlay_style,
3333
fullscreen,
3434
debug,
35-
show_initially,
35+
show_initially = true,
3636
type: spinnerType,
37-
delay_hide,
38-
delay_show,
37+
delay_hide = 0,
38+
delay_show = 0,
3939
target_components,
4040
custom_spinner,
4141
}) => {
@@ -164,15 +164,6 @@ const Loading = ({
164164

165165
Loading._dashprivate_isLoadingComponent = true;
166166

167-
Loading.defaultProps = {
168-
type: 'default',
169-
color: '#119DFF',
170-
delay_show: 0,
171-
delay_hide: 0,
172-
show_initially: true,
173-
display: 'auto',
174-
};
175-
176167
Loading.propTypes = {
177168
/**
178169
* The ID of this component, used to identify dash components

components/dash-core-components/src/components/Tab.react.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ import PropTypes from 'prop-types';
55
* Part of dcc.Tabs - this is the child Tab component used to render a tabbed page.
66
* Its children will be set as the content of that tab, which if clicked will become visible.
77
*/
8-
const Tab = ({children}) => <Fragment>{children}</Fragment>;
8+
9+
/* eslint-disable no-unused-vars */
10+
const Tab = ({
11+
children,
12+
disabled = false,
13+
disabled_style = {color: '#d6d6d6'},
14+
}) => <Fragment>{children}</Fragment>;
15+
/* eslint-enable no-unused-vars */
16+
17+
// Default props are defined above for proper docstring generation in React 18.
18+
// The actual default values are set in Tabs.react.js.
919

1020
Tab.propTypes = {
1121
/**
@@ -84,11 +94,4 @@ Tab.propTypes = {
8494
}),
8595
};
8696

87-
Tab.defaultProps = {
88-
disabled: false,
89-
disabled_style: {
90-
color: '#d6d6d6',
91-
},
92-
};
93-
9497
export default Tab;

components/dash-core-components/src/components/Tabs.react.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const EnhancedTab = ({
1919
selected_style,
2020
selectHandler,
2121
value,
22-
disabled,
23-
disabled_style,
22+
disabled = false,
23+
disabled_style = {color: '#d6d6d6'},
2424
disabled_className,
2525
mobile_breakpoint,
2626
amountOfTabs,

0 commit comments

Comments
 (0)