# Scroll to top when React States Updates

**URL:** <https://forum.ionicframework.com/t/scroll-to-top-when-react-states-updates/218575>\
**Category:** Ionic React\
**Created:** [December 20, 2021, 12:33am UTC](https://forum.ionicframework.com/t/scroll-to-top-when-react-states-updates/218575 "2021-12-20T00:33:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZhaniWalid](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/zhaniwalid/32/138735_2.png) [@ZhaniWalid](https://forum.ionicframework.com/u/ZhaniWalid)\
**Post date:** [December 20, 2021, 12:33am UTC](https://forum.ionicframework.com/t/scroll-to-top-when-react-states-updates/218575/1 "2021-12-20T00:33:46Z")

</div>

Hello,

Is there a solution, to force the scroll bar to scroll to **TOP** when the **React States Updates** on `useEffect()` **hook**?  
I tried `window.scrollTo(0, 0);` but it didn’t worked.  
Any help is appreciated.

Thanks every one from **@ Ionic/React** community developers.

---

<div class="post-metadata">

**Author:** ![mikrochipkid](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mikrochipkid/32/116956_2.png) [@mikrochipkid](https://forum.ionicframework.com/u/mikrochipkid)\
**Post date:** [December 20, 2021, 2:58am UTC](https://forum.ionicframework.com/t/scroll-to-top-when-react-states-updates/218575/2 "2021-12-20T02:58:22Z")

</div>

Use scrollToTop() in your useEffect.

> **[ion-content | Ionic Documentation](https://ionicframework.com/docs/api/content#methods)**
>
> ion-content: Scrollable CSS Component for Ionic App Content Areas

---

<div class="post-metadata">

**Author:** ![ZhaniWalid](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/zhaniwalid/32/138735_2.png) [@ZhaniWalid](https://forum.ionicframework.com/u/ZhaniWalid)\
**Post date:** [December 20, 2021, 9:49am UTC](https://forum.ionicframework.com/t/scroll-to-top-when-react-states-updates/218575/3 "2021-12-20T09:49:00Z")

</div>

Hello @mikrochipkid,

can you give me an example?

Thank you.

---

<div class="post-metadata">

**Author:** ![ZhaniWalid](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/zhaniwalid/32/138735_2.png) [@ZhaniWalid](https://forum.ionicframework.com/u/ZhaniWalid)\
**Post date:** [December 23, 2021, 9:59pm UTC](https://forum.ionicframework.com/t/scroll-to-top-when-react-states-updates/218575/4 "2021-12-23T21:59:30Z")

</div>

I found this solution on #Github from a #Discord channel, and it worked like a charm… I will mark this question as **SOLVED** :

[https://stackoverflow.com/questions/58730178/adding-in-a-scroll-button-with-ionic-react](https://stackoverflow.com/questions/58730178/adding-in-a-scroll-button-with-ionic-react)
