0.5.0
- [BREAKING]
confetti.Promise
is no longer set by default (i.e. if you try to read this value, it will now beundefined
). This property was never documented, and it has now been removed from the implementation.
Note: you can still set
confetti.Promise = MyPromiseLib
to use your custom promises or to polyfill promises without settingwindow.Promise
.
- Server-side rendering is now supported. You can safely use this module in a build that performs server-side rendering.
Note: if you want to trigger
confetti()
inside your render path (i.e. in therender()
method of a class component or directly inside a function component), you will still need to check that you are on the client, as launching confetti is not supported on the server (for obvious reasons). Include a check such as this:
function MyComponent(props) {
// launch some confetti when the component renders
if (typeof window !== 'undefined') {
confetti();
}
return <div>Some page content</div>;
}
class MyComponent extends React.Component {
render() {
// launch some confetti when the component renders
if (typeof window !== 'undefined') {
confetti();
}
return <div>Some page content</div>;
}
}
compare: 0.4.2...0.5.0