-
Notifications
You must be signed in to change notification settings - Fork 11
Minor refactor #35
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
Minor refactor #35
Conversation
c60a72e
to
e305df5
Compare
e305df5
to
081f1c8
Compare
src/PaletteProvider.js
Outdated
LoaderComponent?: | ||
| React$Component<*, *, *> | ||
| ((...args: *) => React$Element<*>), | ||
LoaderComponent?: ReactClass<*> | ((...args: *) => React.Element<*>), |
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.
Let's use Array<*>
or Array<any>
better for the rest parameter.
From the docs: If you add a type annotation to a rest parameter, it must always explicitly be an Array type.
https://flow.org/en/docs/types/functions/#toc-rest-parameters
if (onFinish) onFinish(paletteWithDefaults); | ||
|
||
this.setState({ palette: paletteWithDefaults }); | ||
this.eventEmitter.publish({ |
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.
We need to publish
before setting state, remember the issue we discussed at the office. The change is in my branch anyway, but will be good to have it here as well already 🤖
return <LoaderComponent />; | ||
} | ||
|
||
if (shouldRender) { |
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.
shouldn't we change the order? If forceRender
is provided, it seems natural for me to override LoaderComponent
, what do you think?
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.
Just following what's in the comment in the prop types. cc @zamotany
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.
From the docs: Does not take effect if LoaderComponent is specified!
Besides, why would you specify LoaderComponent
when you would force the render anyway?
try { | ||
failure(new Error('test')); | ||
} catch (error) { | ||
expect(error.message).toMatch(/MaterialPaletteProvider.*test/); |
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.
Why not expect(error.message).toBe('Uncaught MaterialPaletteProvider exception: test')
for more accuracy of what's being thrown?
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.
Blame @zamotany xD
lightVibrant: { ...localDefaults.lightVibrant, population: 0 }, | ||
}); | ||
expect(style).toEqual([{ fontSize: '14px' }, {}]); | ||
expect(StyleSheet.flatten(style)).toEqual({ fontSize: '14px' }); |
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.
Nice! Didn't know about flatten
👍
Also, we need to update the API docs to remove |
081f1c8
to
589b7ae
Compare
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.
Why are we you removing onInit
??
@zamotany it's basically the same as when the provider mounts, so seems unnecessary |
No description provided.