// Copyright 2017-2020 @polkadot/react-components authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import React from 'react'; import ReactDOM from 'react-dom'; import { Draggable, DraggableProvided, DraggableStateSnapshot } from 'react-beautiful-dnd'; import { PORTAL_ID } from '../../../apps/src/Apps'; import AddressToggle from '../AddressToggle'; interface Props { address: string; index: number; onDeselect: (index: number) => void; } const portal = document.getElementById(PORTAL_ID) as Element; function Selected ({ address, index, onDeselect }: Props): React.ReactElement { return ( {(provided: DraggableProvided, snapshot: DraggableStateSnapshot): React.ReactElement => { const element = (
); return snapshot.isDragging ? ReactDOM.createPortal(element, portal) : element; }}
); } export default React.memo(Selected);