-1

want to set loading spinner on popup

I tried to set spinner but its not working .

I'm using functional component approach , all api calls are in popup page so I'm not able to put spinner while all api's gets data in return.

Girish AJ
  • 11
  • 4

1 Answers1

0

You can use useState to create a loading state. Then, when the popup is opened, you should set the loading state to true, and then you should listen for the close event of the popup (see Capture the close event of popup window in JavaScript). When the popup is closed, you can then set the loading state to false.

  • yes , but the button is on first page , and onclick of that button popup is coming , that code is in another page . – Girish AJ Jan 06 '23 at 18:37
  • If you're using react-router, you should move that loading state to the parent component, and otherwise use something like localStorage to keep track of the loading state. Without more code it's hard to help find a solution for your specific use case. – Live bug help - www.dialect.so Jan 06 '23 at 18:39
  • ---------------------------------------------------------------------------------------this is on firstpage and TestGoals.js is popup – Girish AJ Jan 06 '23 at 18:40