Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

connect component with redux

kruzhambusa4b054da4ace
diff --git a/src/pages/Project/View/components/SankeyChart.tsx b/src/pages/Project/View/components/SankeyChart.tsx
index e3cf4bab1..82781c6be 100644
--- a/src/pages/Project/View/components/SankeyChart.tsx
+++ b/src/pages/Project/View/components/SankeyChart.tsx
@@ -81,14 +81,30 @@ const mapStateToProps = (state: StateType) => ({
userFlowDescending: state.ui.cache.userFlowDescending,
})
+const mapDispatchToProps = (dispatch: AppDispatch) => ({
+ setUserFlowAscending: (data: IUserFlow, pid: string, period: string) => {
+ dispatch(UIActions.setUserFlowAscending({
+ data,
+ pid,
+ period,
+ }))
+ },
+ setUserFlowDescending: (data: IUserFlow, pid: string, period: string) => {
+ dispatch(UIActions.setUserFlowDescending({
+ data,
+ pid,
+ period,
+ }))
+ },
+})
+
const SankeyChart = ({
- data, disableLegend, pid, period, timeBucket, from, to, timezone, userFlowAscending, userFlowDescending,
+ disableLegend, pid, period, timeBucket, from, to, timezone, userFlowAscending, userFlowDescending,
}: {
- data?: any
disableLegend?: boolean
pid: string
- userFlowAscending: IUserFlow[]
- userFlowDescending: IUserFlow[]
+ userFlowAscending: IUserFlow
+ userFlowDescending: IUserFlow
period: string
timezone: string
timeBucket: string
@@ -158,8 +174,13 @@ const SankeyChart = ({
)
SankeyChart.defaultProps = {
- data: {},
disableLegend: false,
}
-export default SankeyChart
+const mergeProps = (stateProps: ReturnType<typeof mapStateToProps>, dispatchProps: ReturnType<typeof mapDispatchToProps>, ownProps: ReturnType<typeof SankeyChart>) => ({
+ ...ownProps,
+ ...stateProps,
+ ...dispatchProps,
+})
+
+export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(SankeyChart)