mirror of
https://github.com/pezkuwichain/pezkuwi-ui.git
synced 2026-04-23 11:58:04 +00:00
4c58f48645
* Bump deps * Adjust for new eslint parser
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
// Copyright 2017-2020 @polkadot/react-qr 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 { NetworkSpecsStruct } from '@polkadot/ui-settings';
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
import QrDisplay from './Display';
|
|
|
|
import { encodeString } from './util';
|
|
|
|
interface Props {
|
|
className?: string;
|
|
networkSpecs: NetworkSpecsStruct;
|
|
size?: string | number;
|
|
style?: React.CSSProperties;
|
|
}
|
|
|
|
function DisplayNetworkSpecs ({ className, networkSpecs, size, style }: Props): React.ReactElement<Props> | null {
|
|
const [data, setData] = useState<Uint8Array | null>(null);
|
|
|
|
useEffect((): void => {
|
|
setData(encodeString(JSON.stringify(networkSpecs)));
|
|
}, [networkSpecs]);
|
|
|
|
if (!data) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<QrDisplay
|
|
className={className}
|
|
size={size}
|
|
skipEncoding
|
|
style={style}
|
|
value={data}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default React.memo(DisplayNetworkSpecs);
|