-
-
Notifications
You must be signed in to change notification settings - Fork 733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw error when resolver is not an object + Better error messages when deserializing unknown nodes #133
Conversation
be found in resolver
resolver will never be undefined
Deploy preview for craftjs ready! Built with commit 4b199c0 |
I replaced RTL with enzyme. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welcome back! Looks good, just 1 tiny suggestion!
invariant( | ||
(Comp !== undefined && typeof Comp === 'string' && Comp.length > 0) || | ||
(Comp as { resolvedName?: string }).resolvedName !== undefined, | ||
ERROR_DESERIALIZE_COMPONENT_NOT_IN_RESOLVER.replace( | ||
'%displayName%', | ||
data.displayName | ||
).replace('%availableComponents%', Object.keys(resolver).join(', ')) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we break this line up so it is more readable?
Ie:
invariant( | |
(Comp !== undefined && typeof Comp === 'string' && Comp.length > 0) || | |
(Comp as { resolvedName?: string }).resolvedName !== undefined, | |
ERROR_DESERIALIZE_COMPONENT_NOT_IN_RESOLVER.replace( | |
'%displayName%', | |
data.displayName | |
).replace('%availableComponents%', Object.keys(resolver).join(', ')) | |
); | |
const isCompHtmlElement = Comp !== undefined && typeof Comp === 'string'; | |
const isCompUserComponent = Comp !== undefined && (Comp as { resolvedName?: string }).resolvedName !== undefined; | |
invariant(isCompHtmlElement || isCompUserComponent, '....') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, done
Yay I'm back. With a smaller change this time.
This should help to prevent some common beginner mistakes.
Display an error when
resolver
on<Editor />
is not an objectDisplay an error which component cannot be resolved