Skip to content
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

Can't set customLoading equal true again after get request api #23

Open
datnguyenute opened this issue Oct 13, 2019 · 3 comments
Open

Comments

@datnguyenute
Copy link

Describe the bug
When i using customLoading to set status for pre-loading with request api, i can't set customLoading equals TRUE again with another request.

Expected behavior
Can setting customLoading and preloader is display again with each request

Code
In my render function
<h1>My app</h1>
<Lines customLoading={this.state.loading} />
<button onClick={() => this.setState({ loading: true })}>Another Request</button>
<h3>{this.state.loading ? 'true' : 'false' } </h3>
When i change state by click button "Another Request", state has change, but my preloader not reset customLoading and have no display preloader

@xAl3xFx
Copy link

xAl3xFx commented Feb 1, 2020

Please respond to this question I'm facing the same issue.

@am0nshi
Copy link

am0nshi commented Jun 27, 2020

@VamOSGS could this one be fixed? facing same issue and didn't see any inner processing for "true" state?
best regards, Nike

@charles-dr
Copy link

charles-dr commented Sep 15, 2020

I met the same issue, and push a PR.
Or you can edit the package file in the project, of cos, for temporary usage.
In './node_modules/react-preloaders/Preloader/StyledPreloader.js',

// from line 84
bodyScroll();
  (0, _react.useEffect)(function () {
    if (customLoading === false) {
      setTimeout(function () {
        setLoading(false);
      }, time);
    }

    if (customLoading === undefined) {
      document.onreadystatechange = function () {
        if (document.readyState === 'complete') {
          setTimeout(function () {
            setLoading(false);
          }, time);
        }
      };
    }
    if (customLoading === true) {    // added these 3 lines
      setLoading(true);
    }
  }, [customLoading]);

Hope it helps save you time. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants