jiti-meet/react/features/polls/components/AbstractPollsPane.js

45 lines
1.1 KiB
JavaScript

// @flow
import React, { useState } from 'react';
import type { AbstractComponent } from 'react';
import { useTranslation } from 'react-i18next';
/*
* Props that will be passed by the AbstractPollsPane to its
* concrete implementations (web/native).
**/
export type AbstractProps = {
createMode: boolean,
onCreate: void => void,
setCreateMode: boolean => void,
t: Function,
};
/**
* Higher Order Component taking in a concrete PollsPane component and
* augmenting it with state/behavior common to both web and native implementations.
*
* @param {React.AbstractComponent} Component - The concrete component.
* @returns {React.AbstractComponent}
*/
const AbstractPollsPane = (Component: AbstractComponent<AbstractProps>) => () => {
const [ createMode, setCreateMode ] = useState(false);
const onCreate = () => {
setCreateMode(true);
};
const { t } = useTranslation();
return (<Component
createMode = { createMode }
/* eslint-disable react/jsx-no-bind */
onCreate = { onCreate }
setCreateMode = { setCreateMode }
t = { t } />);
};
export default AbstractPollsPane;