diff --git a/packages/core/src/editor/Editor.tsx b/packages/core/src/editor/Editor.tsx index f00666bc0..a0d3a6cc3 100644 --- a/packages/core/src/editor/Editor.tsx +++ b/packages/core/src/editor/Editor.tsx @@ -18,7 +18,9 @@ export const Editor: React.FC>> = ({ // we do not want to warn the user if no resolver was supplied if (options.resolver !== undefined) { invariant( - typeof options.resolver === 'object' && !Array.isArray(options.resolver), + typeof options.resolver === 'object' && + !Array.isArray(options.resolver) && + options.resolver !== null, ERROR_RESOLVER_NOT_AN_OBJECT ); } diff --git a/packages/core/src/editor/tests/editor.test.tsx b/packages/core/src/editor/tests/editor.test.tsx new file mode 100644 index 000000000..74b999fd2 --- /dev/null +++ b/packages/core/src/editor/tests/editor.test.tsx @@ -0,0 +1,15 @@ +import { ERROR_RESOLVER_NOT_AN_OBJECT } from '@craftjs/utils'; +import { render } from '@testing-library/react'; +import * as React from 'react'; + +import { Resolver } from '../../interfaces'; +import { Editor } from '../Editor'; + +describe('Editor Component', () => { + it('should throw an error when we use with resolvers that are not valid objects', () => { + expect(() => { + const resolver = (null as unknown) as Resolver; + render(); + }).toThrowError(ERROR_RESOLVER_NOT_AN_OBJECT); + }); +});