grafana/public/app/core/utils/connectWithReduxStore.tsx

26 lines
801 B
TypeScript
Raw Normal View History

2018-10-23 09:00:04 -05:00
import React from 'react';
import { connect, Provider } from 'react-redux';
2018-11-05 09:54:48 -06:00
import { store } from '../../store/store';
2018-10-23 09:00:04 -05:00
export function connectWithStore(WrappedComponent: any, ...args: any[]) {
2019-05-13 02:38:19 -05:00
const ConnectedWrappedComponent = (connect as any)(...args)(WrappedComponent);
2018-10-23 09:00:04 -05:00
// eslint-disable-next-line react/display-name
return (props: any) => {
2018-10-23 09:00:04 -05:00
return <ConnectedWrappedComponent {...props} store={store} />;
};
}
export function connectWithProvider(WrappedComponent: any, ...args: any[]) {
const ConnectedWrappedComponent = (connect as any)(...args)(WrappedComponent);
// eslint-disable-next-line react/display-name
return (props: any) => {
return (
<Provider store={store}>
<ConnectedWrappedComponent {...props} store={store} />
</Provider>
);
};
}