Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import NProgress, { NProgressOptions } from 'nprogress';
console.log(NProgress.status);
console.log(NProgress.version);
// $ExpectType NProgress
NProgress.start();
NProgress.inc()
.inc(0.2)
.done();
NProgress.set(0.5);
NProgress.trickle();
console.log(NProgress.isStarted());
NProgress.done(true);
NProgress.configure({ minimum: 0.1 });
NProgress.configure({
template: '<div></div>',
easing: 'ease',
speed: 500,
trickle: true,
showSpinner: false,
trickleSpeed: 250,
parent: '#content',
// $ExpectError
foo: ''
});
public componentWillUnmount() {
if (this.timer) {
clearTimeout(this.timer);
}
if (NProgress.isStarted()) {
NProgress.done();
}
}
function stop() {
if (nprogress.isStarted()) {
nprogress.done();
}
}
componentDidMount() {
if (NProgress.isStarted()) {
NProgress.done()
}
}
componentDidUpdate() {
if (NProgress.isStarted()) {
NProgress.done()
}
}
public componentDidUpdate(prevProps: IProgressProps) {
if (prevProps.isFetching === this.props.isFetching) {
return;
}
if (this.props.isFetching) {
this.timer = window.setTimeout(() => NProgress.start(), 150);
} else {
if (this.timer) {
clearTimeout(this.timer);
}
if (NProgress.isStarted()) {
NProgress.done();
}
}
}