diff --git a/CHANGELOG.md b/CHANGELOG.md index 89ef9741b53..6fdb3b08e22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ No public interface changes since `22.5.0`. **Bug Fixes** +- Fixed EuiI8n hasPropName utility errors on null values ([#3303](https://github.com/elastic/eui/pull/3303)) - Fixed the inline styles being overwritten by consumer-passed inline styles in EuiBadge ([#3284](https://github.com/elastic/eui/pull/3284)) ## [`22.4.0`](https://github.com/elastic/eui/tree/v22.4.0) diff --git a/src/components/i18n/__snapshots__/i18n.test.tsx.snap b/src/components/i18n/__snapshots__/i18n.test.tsx.snap index 19f03d22b70..462989707db 100644 --- a/src/components/i18n/__snapshots__/i18n.test.tsx.snap +++ b/src/components/i18n/__snapshots__/i18n.test.tsx.snap @@ -135,6 +135,22 @@ exports[`EuiI18n default rendering rendering to dom renders a string with placeh `; +exports[`EuiI18n default rendering rendering to dom renders when value is null 1`] = ` + + + +`; + exports[`EuiI18n reading values from context mappingFunc calls the mapping function with the source string 1`] = ` { expect(renderCallback).toHaveBeenCalledWith(values); }); + + it('renders when value is null', () => { + const component = mount( + + ); + expect(component).toMatchSnapshot(); + }); }); describe('render prop with single token', () => { diff --git a/src/components/i18n/i18n_util.tsx b/src/components/i18n/i18n_util.tsx index f51b13afff4..4d783b5fc45 100644 --- a/src/components/i18n/i18n_util.tsx +++ b/src/components/i18n/i18n_util.tsx @@ -14,7 +14,9 @@ function isPrimitive(value: ReactChild) { type Child = string | { propName: string } | ReactChild | undefined; function hasPropName(child: Child): child is { propName: string } { - return typeof child === 'object' && child.hasOwnProperty('propName'); + return child + ? typeof child === 'object' && child.hasOwnProperty('propName') + : false; } /**