Skip to content

Commit ed0ba96

Browse files
committed
Check if a string prop is set instead of inspecting the contents of the string
1 parent 52b0f0f commit ed0ba96

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

packages/connect-react/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<!-- markdownlint-disable MD024 -->
22
# Changelog
33

4+
# [1.0.0-preview.20] - 2025-01-16
5+
6+
- Check if a string prop is set instead of inspecting the contents of the string
7+
48
# [1.0.0-preview.15] - 2024-12-18
59

610
- Emit dynamic props via `onUpdateDynamicProps`

packages/connect-react/src/utils/component.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,13 @@ export function integerPropErrors(opts: ValidationOpts<ConfigurablePropInteger>)
9494
}
9595

9696
export function stringPropErrors(opts: ValidationOpts<ConfigurablePropString>): string[] | undefined {
97-
const _value = valueFromOption(opts.value)
97+
const {
98+
prop, value: valueOpt,
99+
} = opts
98100

99-
if (!opts.prop.default) {
100-
if (typeof _value === "undefined" || _value == null) {
101-
return [
102-
"required",
103-
]
104-
}
105-
}
101+
if (!prop.default && (valueOpt == null || typeof value === "undefined")) return [
102+
"required",
103+
]
106104
}
107105

108106
type AppWithExtractedCustomFields = App & {

0 commit comments

Comments
 (0)