File tree 3 files changed +8
-3
lines changed
3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,10 @@ import withIntl from './injectIntl';
9
9
import { BaseFormattedMessage } from './message' ;
10
10
11
11
class FormattedHTMLMessage extends BaseFormattedMessage {
12
+ static defaultProps = {
13
+ ...BaseFormattedMessage . defaultProps ,
14
+ tagName : 'span' as 'span' ,
15
+ } ;
12
16
render ( ) {
13
17
const { formatHTMLMessage, textComponent : Text } = this . props . intl ;
14
18
@@ -17,7 +21,8 @@ class FormattedHTMLMessage extends BaseFormattedMessage {
17
21
description,
18
22
defaultMessage,
19
23
values : rawValues ,
20
- tagName : Component = Text ,
24
+ // This is bc of TS3.3 doesn't recognize `defaultProps`
25
+ tagName : Component = Text || 'span' ,
21
26
children,
22
27
} = this . props ;
23
28
Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ export class BaseFormattedMessage extends React.Component<Props> {
153
153
if ( Component ) {
154
154
// Needs to use `createElement()` instead of JSX, otherwise React will
155
155
// warn about a missing `key` prop with rich-text message formatting.
156
- return < Component > { nodes } </ Component > ;
156
+ return React . createElement ( Component , null , ... nodes ) ;
157
157
}
158
158
return nodes ;
159
159
}
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export interface IntlConfig {
14
14
locale : string ;
15
15
timeZone ?: string ;
16
16
formats : CustomFormats ;
17
- textComponent : React . ComponentType | keyof React . ReactHTML ;
17
+ textComponent ? : React . ComponentType | keyof React . ReactHTML ;
18
18
messages : Record < string , string > | Record < string , MessageFormatElement [ ] > ;
19
19
defaultLocale : string ;
20
20
defaultFormats : CustomFormats ;
You can’t perform that action at this time.
0 commit comments