function withStateSlice(Comp, slice) { const MemoComp = React.memo(Comp); function Wrapper(props, ref) { const state = useAppState(); const cell = slice(state, props); return ; } Wrapper.displayName = `withStateSlice(${Comp.displayName || Comp.name})`; return React.memo(React.forwardRef(Wrapper)); }