diff --git a/pkg/webui/console/components/pubsub-form/index.js b/pkg/webui/console/components/pubsub-form/index.js index 2ff8ae28e0e..3d62c6961d5 100644 --- a/pkg/webui/console/components/pubsub-form/index.js +++ b/pkg/webui/console/components/pubsub-form/index.js @@ -62,7 +62,6 @@ const PubsubForm = props => { existCheck, onDelete, } = props - const [initialValues, setInitialValues] = useState(blankValues) const [error, setError] = useState(undefined) const [provider, setProvider] = useState(blankValues._provider) const [mqttSecure, setMqttSecure] = useState(true) @@ -71,11 +70,15 @@ const PubsubForm = props => { const [displayOverwriteModal, setDisplayOverwriteModal] = useState(false) const [existingId, setExistingId] = useState(undefined) - useEffect(() => { + const initialValues = useMemo(() => { if (update && initialPubsubValue) { - setInitialValues(mapPubsubToFormValues(initialPubsubValue)) + return mapPubsubToFormValues(initialPubsubValue) + } + return { + ...blankValues, + _provider: provider, } - }, [initialPubsubValue, update]) + }, [initialPubsubValue, provider, update]) useEffect(() => { if (natsDisabled && mqttDisabled) {