import React from 'react';
import { Provider } from 'react-redux';
import { store } from '../../store';

export const withReduxStore = <Props,>(Component: React.ComponentType<any>) => {
  const Wrapper = (props: Props) => {
    return (
      <Provider store={store} >
        <Component {...props} />
      </Provider>
    );
  };
  return Wrapper;
};

export const withReduxStoreAndRefForwarding = <Props, Ref>(Component: React.ComponentType<any>) => React.forwardRef<Ref, Props>((props, ref) => {
  return (
    <Provider store={store}>
      <Component ref={ref} {...props} />
    </Provider>
  );
});
