Hydrate body ranges for story replies
This commit is contained in:
parent
9f85db3fd8
commit
be6e988a95
39 changed files with 221 additions and 172 deletions
|
@ -27,13 +27,11 @@ export type Props = {
|
|||
renderText?: RenderTextCallbackType;
|
||||
};
|
||||
|
||||
export class Intl extends React.Component<Props> {
|
||||
public static defaultProps: Partial<Props> = {
|
||||
renderText: ({ text, key }) => (
|
||||
<React.Fragment key={key}>{text}</React.Fragment>
|
||||
),
|
||||
};
|
||||
const defaultRenderText: RenderTextCallbackType = ({ text, key }) => (
|
||||
<React.Fragment key={key}>{text}</React.Fragment>
|
||||
);
|
||||
|
||||
export class Intl extends React.Component<Props> {
|
||||
public getComponent(
|
||||
index: number,
|
||||
placeholderName: string,
|
||||
|
@ -74,7 +72,7 @@ export class Intl extends React.Component<Props> {
|
|||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
public override render() {
|
||||
const { components, id, i18n, renderText } = this.props;
|
||||
const { components, id, i18n, renderText = defaultRenderText } = this.props;
|
||||
|
||||
if (!id) {
|
||||
log.error('Error: Intl id prop not provided');
|
||||
|
@ -96,12 +94,6 @@ export class Intl extends React.Component<Props> {
|
|||
> = [];
|
||||
const FIND_REPLACEMENTS = /\$([^$]+)\$/g;
|
||||
|
||||
// We have to do this, because renderText is not required in our Props object,
|
||||
// but it is always provided via defaultProps.
|
||||
if (!renderText) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Array.isArray(components) && components.length > 1) {
|
||||
throw new Error(
|
||||
'Array syntax is not supported with more than one placeholder'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue