[MM-32734] Convert value to string to prevent crash (#5164)
* Convert value to string * Add default value prop
This commit is contained in:
parent
5101927e45
commit
ed4b100962
2 changed files with 13 additions and 1 deletions
|
|
@ -73,6 +73,7 @@ export default class Markdown extends PureComponent {
|
|||
disableChannelLink: false,
|
||||
disableAtChannelMentionHighlight: false,
|
||||
disableGallery: false,
|
||||
value: '',
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
|
|
@ -444,7 +445,7 @@ export default class Markdown extends PureComponent {
|
|||
};
|
||||
|
||||
render() {
|
||||
let ast = this.parser.parse(this.props.value);
|
||||
let ast = this.parser.parse(this.props.value.toString());
|
||||
|
||||
ast = combineTextNodes(ast);
|
||||
ast = addListItemIndices(ast);
|
||||
|
|
|
|||
|
|
@ -44,4 +44,15 @@ describe('Markdown', () => {
|
|||
<Markdown {...props}/>,
|
||||
);
|
||||
});
|
||||
|
||||
test('should not crash when given a non-string value', () => {
|
||||
const props = {
|
||||
...baseProps,
|
||||
value: 10,
|
||||
};
|
||||
|
||||
shallow(
|
||||
<Markdown {...props}/>,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue