# How can I programmatically trigger IonRefresher in Ionic 5 React?

**URL:** <https://forum.ionicframework.com/t/how-can-i-programmatically-trigger-ionrefresher-in-ionic-5-react/199311>\
**Category:** Ionic React\
**Created:** [November 9, 2020, 10:43am UTC](https://forum.ionicframework.com/t/how-can-i-programmatically-trigger-ionrefresher-in-ionic-5-react/199311 "2020-11-09T10:43:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ifankai](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@ifankai](https://forum.ionicframework.com/u/ifankai)\
**Post date:** [November 9, 2020, 10:43am UTC](https://forum.ionicframework.com/t/how-can-i-programmatically-trigger-ionrefresher-in-ionic-5-react/199311/1 "2020-11-09T10:43:14Z")

</div>

How can I programmatically trigger IonRefresher when I click the button?

```auto
<IonContent ref={ionContentRef} slot="fixed">
          
          <IonRefresher
            slot="fixed"          
            onIonRefresh={(e) => {
              doRefresh();
            }}
            ref={ionRefresherRef}>
            <IonRefresherContent
              pullingIcon={null}
              refreshingSpinner="bubbles"
            ></IonRefresherContent>
          </IonRefresher>
...
...
<IonButton onClick={refreshByClickButton}></IonButton>
</IonContent>

```

---

<div class="post-metadata">

**Author:** ![EinfachHans](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/einfachhans/32/130917_2.png) [@EinfachHans](https://forum.ionicframework.com/u/EinfachHans)\
**Post date:** [November 9, 2020, 10:50am UTC](https://forum.ionicframework.com/t/how-can-i-programmatically-trigger-ionrefresher-in-ionic-5-react/199311/2 "2020-11-09T10:50:19Z")

</div>

Currently not possible. I created a PR some time ago: [https://github.com/ionic-team/ionic-framework/pull/21972](https://github.com/ionic-team/ionic-framework/pull/21972)

Give it a like maybe to prio is higher 😊

---

<div class="post-metadata">

**Author:** ![OrganGrindingMonkey](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/organgrindingmonkey/32/131678_2.png) [@OrganGrindingMonkey](https://forum.ionicframework.com/u/OrganGrindingMonkey)\
**Post date:** [November 17, 2020, 1:54pm UTC](https://forum.ionicframework.com/t/how-can-i-programmatically-trigger-ionrefresher-in-ionic-5-react/199311/3 "2020-11-17T13:54:29Z")

</div>

I hate to be _that_ guy, but why would you want to do that.

Just use your own loader/spinner or whatever you want… except the IonRefresher.

Create it as a component with flashy gif’s etc. that’s controlled through global state and then use it throughout your application and give the user a consistent experience.

---

<div class="post-metadata">

**Author:** ![AlexThunder](https://avatars.discourse-cdn.com/v4/letter/a/ecb155/32.png) [@AlexThunder](https://forum.ionicframework.com/u/AlexThunder)\
**Post date:** [April 6, 2021, 1:34pm UTC](https://forum.ionicframework.com/t/how-can-i-programmatically-trigger-ionrefresher-in-ionic-5-react/199311/4 "2021-04-06T13:34:28Z")

</div>

‘give the user a consistent experience’  
exactly. To have a single animation/whatever that says “i am refreshing something”. And since the ionRefresher is already there, why not trigger that instead of making your own custom animation/spinner that basically does the same thing?

---

<div class="post-metadata">

**Author:** ![OrganGrindingMonkey](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/organgrindingmonkey/32/131678_2.png) [@OrganGrindingMonkey](https://forum.ionicframework.com/u/OrganGrindingMonkey)\
**Post date:** [April 12, 2021, 4:43pm UTC](https://forum.ionicframework.com/t/how-can-i-programmatically-trigger-ionrefresher-in-ionic-5-react/199311/5 "2021-04-12T16:43:06Z")

</div>

Because it was, at the time of writing… not possible?

---

<div class="post-metadata">

**Author:** ![iwantwin](https://avatars.discourse-cdn.com/v4/letter/i/94ad74/32.png) [@iwantwin](https://forum.ionicframework.com/u/iwantwin)\
**Post date:** [May 15, 2021, 9:57am UTC](https://forum.ionicframework.com/t/how-can-i-programmatically-trigger-ionrefresher-in-ionic-5-react/199311/6 "2021-05-15T09:57:18Z")

</div>

It had been possible in earlier versions of ionic, that’s why we want it. I’m currently upgrading an app from ionic 3 to ionic 5, and this possibility is lost in time. I would really like to have it back 😉

---

<div class="post-metadata">

**Author:** ![alex87](https://avatars.discourse-cdn.com/v4/letter/a/b3f665/32.png) [@alex87](https://forum.ionicframework.com/u/alex87)\
**Post date:** [November 14, 2022, 9:10am UTC](https://forum.ionicframework.com/t/how-can-i-programmatically-trigger-ionrefresher-in-ionic-5-react/199311/7 "2022-11-14T09:10:19Z")

</div>

With React it’s possbile:

`const refresher = useRef<HTMLIonRefresherElement>(null);`

```auto
	const handleRefresh = () => {
		if (refresher.current) {
			refresher.current.classList.add('refresher-active');
			refresher.current.classList.add('refresher-refreshing');

			setTimeout(() => {
				refresher.current!.complete();
				refresher.current!.classList.remove('refresher-active');
				refresher.current!.classList.remove('refresher-refreshing');
			}, 2000);
		}
	};

```

```auto
<IonRefresher 
    ref={refresher} 
    slot="fixed" 
    onIonRefresh={handleRefresh}
>
        <IonRefresherContent />
</IonRefresher>

```

Useful if you want to programatically do a refresh and reuse the same indicator

---

<div class="post-metadata">

**Author:** ![ommishk](https://avatars.discourse-cdn.com/v4/letter/o/f04885/32.png) [@ommishk](https://forum.ionicframework.com/u/ommishk)\
**Post date:** [November 14, 2022, 9:35am UTC](https://forum.ionicframework.com/t/how-can-i-programmatically-trigger-ionrefresher-in-ionic-5-react/199311/8 "2022-11-14T09:35:25Z")

</div>

THE [digital marketing agency](https://schwayverse.com/) which provide content writting or many more

---

<div class="post-metadata">

**Author:** ![deepak21saini0](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@deepak21saini0](https://forum.ionicframework.com/u/deepak21saini0)\
**Post date:** [March 15, 2023, 5:32pm UTC](https://forum.ionicframework.com/t/how-can-i-programmatically-trigger-ionrefresher-in-ionic-5-react/199311/9 "2023-03-15T17:32:08Z")

</div>

@alex87 - Is the code working for you? I need to implement this in ionic Vue.
