From 2c4330deb67ac21ee9bc9000ffb06bd2046aebff Mon Sep 17 00:00:00 2001 From: Tristan Huet Date: Thu, 27 Apr 2023 11:06:15 +0200 Subject: [PATCH] fix: fix console warning regarding undefined required prop During transition between scenarios with different run templates, the default value for a given scenario parameter may temporarily not be available. This leads to console warnings because the defaultParameterValue prop was decalred as required. Yet, it does not need to be required: the component could use null or undefined as a default value, or wait for the actual default value to be retrieved during transitions between scenarios. --- .../components/ScenarioParametersInputs/GenericNumberInput.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/ScenarioParameters/components/ScenarioParametersInputs/GenericNumberInput.js b/src/components/ScenarioParameters/components/ScenarioParametersInputs/GenericNumberInput.js index 4cc502558..fb77343b0 100644 --- a/src/components/ScenarioParameters/components/ScenarioParametersInputs/GenericNumberInput.js +++ b/src/components/ScenarioParameters/components/ScenarioParametersInputs/GenericNumberInput.js @@ -77,9 +77,10 @@ GenericNumberInput.propTypes = { context: PropTypes.object.isRequired, parameterValue: PropTypes.any, setParameterValue: PropTypes.func.isRequired, - defaultParameterValue: PropTypes.number.isRequired, + defaultParameterValue: PropTypes.number, isDirty: PropTypes.bool, }; + GenericNumberInput.defaultProps = { isDirty: false, };