[MM-32734] Convert value to string to prevent crash (#5164)

* Convert value to string

* Add default value prop
This commit is contained in:
Miguel Alatzar 2021-02-10 14:39:01 -07:00 committed by GitHub
parent 5101927e45
commit ed4b100962
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -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);

View file

@ -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}/>,
);
});
});