Migrated to typescript first component getting another component with props injected

This commit is contained in:
Alejandro Celaya
2020-08-22 13:41:54 +02:00
parent 39663ba936
commit 2db85c2783
7 changed files with 81 additions and 72 deletions

View File

@@ -5,14 +5,17 @@ import { Server } from '../data';
type Ref<T> = RefObject<T> | MutableRefObject<T>;
interface ImportServersBtnProps {
createServers: (servers: Server[]) => void;
fileRef: Ref<HTMLInputElement>;
export interface ImportServersBtnProps {
onImport?: () => void;
}
interface ImportServersBtnConnectProps {
createServers: (servers: Server[]) => void;
fileRef: Ref<HTMLInputElement>;
}
const ImportServersBtn = ({ importServersFromFile }: ServersImporter) => (
{ createServers, fileRef, onImport = () => {} }: ImportServersBtnProps,
{ createServers, fileRef, onImport = () => {} }: ImportServersBtnConnectProps & ImportServersBtnProps,
) => {
const ref = fileRef ?? useRef<HTMLInputElement>();
const onChange = async ({ target }: ChangeEvent<HTMLInputElement>) =>