rikmms / progress-bar-4-axios

Slim progress bar (NProgress) for Web applications that use Axios library for HTTP requests
MIT License
246 stars 32 forks source link

Can't use with react #10

Closed vaibhavhrt closed 4 years ago

vaibhavhrt commented 5 years ago

I have tried multiple things but still can't get it to work with react. It would be nice if you can add a few examples in repo showing working examples in different cases.

stelone commented 5 years ago

Work fine for me !

Simply do this in App.js

import { loadProgressBar } from 'axios-progress-bar';
import 'axios-progress-bar/dist/nprogress.css';

class App extends Component {
    componentDidMount() {
          loadProgressBar();
    }
}
mjjf commented 5 years ago

@vaibhavhrt What is your specific problem? Using an axios instance and the default config has worked well for me:

import axios from 'axios';
import { loadProgressBar } from 'axios-progress-bar'

const api = () => {
    const httpConfig = {
        baseURL: "localhost:12345"
    };

    const instance = axios.create(httpConfig);
    loadProgressBar(null, instance);

    return instance;
};

export default api;
sibi-sharanyan commented 4 years ago

Not sure what I'm doing wrong, But the progress bar loads only to 1/4th of the screen and disappears in my case.

leopucci commented 3 years ago

The progressbar is not showing to me also. I have loaded with an instance, the css code is loaded on and js is called after axios instance.create. Is just that? a css code and js call? who is creating the div/positioning? Any ideas?