I'm trying to call dispatch inside a class. All possible ways to do this lead me to an dead end. Maybe is my case a little special:
I have a class which I nead to override and from inside an overridden function I do need to call dispatch.
class RolloverModifierEx extends RolloverModifier {
override hitTestRenderableSeries(rs: IRenderableSeries, mousePoint: Point): HitTestInfo {
const hitTest = rs.hitTestProvider.hitTestXSlice(mousePoint.x, mousePoint.y, this.hitTestRadius);
// some code ...
this.dispatch(updateCurrentValue({
title: dataSeriesName ,
currentValue: yValueCalculated)
}));
// some more code ...
return hitTest;
}
}
I've tried different ways like using "connect" from react-redux, or making a wrapper class for the dispatch, but all things brought me to the same problem that is isn't possible to call dispatch from outside a react component.
I'm kind of clueless and really need help...
Found The solution for the problem:
I used the constructor to pass the store into the class and then I can call dispatch on that. Thanks at @Javokhir for the hint with the store.
From outside this is then called like this: