// Copyright 2017-2021 @polkadot/react-params authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Props } from '../types'; import React, { useCallback, useState } from 'react'; import { isWasm } from '@polkadot/util'; import Bytes from './Bytes'; import BytesFile from './File'; function Code ({ className = '', defaultValue, isDisabled, isError, label, onChange, onEnter, onEscape, type, withLabel }: Props): React.ReactElement { const [isValid, setIsValid] = useState(false); const _onChange = useCallback( (value: Uint8Array): void => { const isValid = isWasm(value); onChange && onChange({ isValid, value }); setIsValid(isValid); }, [onChange] ); if (isDisabled) { return ( ); } return ( ); } export default React.memo(Code);