I am using ag grid in one my react applications. I am initializing my grid in one of the components and saving the gridApi on a state variable by useState inside onGridReady method.
The thing is, I want to access gridApi from some other components also. What's the best practice for it? For example, I am initializing my grid in X component and I want to access gridApi from Y component also. Currently I am storing the gridApi on redux and retrieving it from store whenever it's needed from other components. Is there any other better way to do it? Also is there any pitfall of storing gridApi in redux?
Thank you.