Skip to content

Commit 9e78952

Browse files
authored
fix: Add type checking to value (#242)
1 parent b30cee5 commit 9e78952

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ const ReactCodeMirror = React.forwardRef<ReactCodeMirrorRef, ReactCodeMirrorProp
123123
// eslint-disable-next-line react-hooks/exhaustive-deps
124124
}, []);
125125

126+
// check type of value
127+
if (typeof value !== 'string') {
128+
throw new Error(`value must be typeof string but got ${typeof value}`);
129+
}
130+
126131
const defaultClassNames = typeof theme === 'string' ? `cm-theme-${theme}` : 'cm-theme';
127132
return <div ref={editor} className={`${defaultClassNames}${className ? ` ${className}` : ''}`} {...other}></div>;
128133
});

0 commit comments

Comments
 (0)