Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export interface MarkdownProps extends ReactRendererOptions, LexerOptions {
}

const validateComponentProps = (props: MarkdownProps) => {
if (props.value && typeof props.value !== 'string') {
if (props.value != null && typeof props.value !== 'string') {
throw new TypeError(`[marked-react]: Expected value to be of type string but got ${typeof props.value}`);
}

if (props.children && typeof props.children !== 'string') {
if (props.children != null && typeof props.children !== 'string') {
throw new TypeError(`[marked-react]: Expected children to be of type string but got ${typeof props.children}`);
}
};
Expand Down
2 changes: 1 addition & 1 deletion tests/component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Markdown Component', () => {
});

it('should throw error if children is not a string', () => {
const marked = createElement(Markdown, null, 1);
const marked = createElement(Markdown, null, 0);

expect(() => renderToStaticMarkup(marked)).toThrowError(
new TypeError('[marked-react]: Expected children to be of type string but got number'),
Expand Down