import WrappedScreenContext from 'components/WrappedScreenContext';
import { RootState } from 'models';
import React from 'react';
import { useSelector } from 'react-redux';
import Screen from 'components/ScreenPreview';

const ScreenContainer = () => {
  const screenDetail = useSelector((state: RootState) => state.screenDetail);

  if(!screenDetail){
    return null;
  }

  const { id } = screenDetail;

  return <Screen id={id} />;
};

export default ({ getScreenInfo, emitEvent }) => WrappedScreenContext({ getScreenInfo, emitEvent })(ScreenContainer);
