Exhaustive hooks (#294)

This commit is contained in:
Jaco Greeff
2020-03-27 08:41:35 +01:00
committed by GitHub
parent d92a02dff4
commit 32f52dfc13
8 changed files with 402 additions and 361 deletions
+4 -4
View File
@@ -7,9 +7,9 @@
"packages/*"
],
"resolutions": {
"@polkadot/api": "^1.9.0-beta.11",
"@polkadot/api": "^1.9.0-beta.12",
"@polkadot/keyring": "^2.7.0-beta.8",
"@polkadot/types": "^1.9.0-beta.11",
"@polkadot/types": "^1.9.0-beta.12",
"@polkadot/util": "^2.7.0-beta.8",
"@polkadot/util-crypto": "^2.7.0-beta.8",
"babel-core": "^7.0.0-bridge.0",
@@ -28,8 +28,8 @@
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@polkadot/dev": "^0.51.8",
"@polkadot/typegen": "^1.9.0-beta.11",
"@polkadot/dev": "^0.51.9",
"@polkadot/typegen": "^1.9.0-beta.12",
"@types/jest": "^25.1.4",
"copy-webpack-plugin": "^5.1.1",
"sinon-chrome": "^3.0.1"
+1 -1
View File
@@ -6,7 +6,7 @@
"license": "Apache-2",
"dependencies": {
"@babel/runtime": "^7.9.2",
"@polkadot/api": "^1.9.0-beta.11",
"@polkadot/api": "^1.9.0-beta.12",
"@polkadot/keyring": "^2.7.0-beta.8",
"@polkadot/ui-keyring": "^0.52.0-beta.20",
"extensionizer": "^1.0.1"
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import React, { useState, useEffect } from 'react';
import React, { useCallback, useState } from 'react';
import { Button, InputWithLabel } from '../../components';
@@ -16,15 +16,18 @@ export default function Unlock ({ className, onSign, buttonText = 'Sign the tran
const [error, setError] = useState('');
const [password, setPassword] = useState('');
useEffect((): void => {
if (error) {
const _onChangePassword = useCallback(
(password: string): void => {
setPassword(password);
setError('');
}
}, [password]);
const _onClick = (): Promise<void> =>
onSign(password)
.catch((error): void => setError(error.message));
},
[]
);
const _onClick = useCallback(
(): Promise<void> =>
onSign(password).catch((error): void => setError(error.message)),
[onSign, password]
);
return (
<div className={className}>
@@ -32,7 +35,7 @@ export default function Unlock ({ className, onSign, buttonText = 'Sign the tran
isError={!password || !!error}
isFocused
label='Password for this account'
onChange={setPassword}
onChange={_onChangePassword}
type='password'
/>
<Button onClick={_onClick}>{buttonText}</Button>
@@ -22,9 +22,11 @@ export default function Signing (): React.ReactElement<{}> {
);
useEffect(() => {
if (requestIndex >= requests.length) {
setRequestIndex(requests.length - 1);
}
setRequestIndex(
(requestIndex) => requestIndex >= requests.length
? requests.length - 1
: requestIndex
);
}, [requests]);
return requests[requestIndex] ? (
+1 -1
View File
@@ -33,7 +33,7 @@ export default function Name ({ address, className, defaultValue, isFocussed, la
? name
: null
);
}, [name]);
}, [name, onChange]);
return (
<InputWithLabel
@@ -23,7 +23,7 @@ export default function Password ({ isFocussed, onChange }: Props): React.ReactE
? pass1
: null
);
}, [pass1, pass2]);
}, [onChange, pass1, pass2]);
return (
<>
+1 -1
View File
@@ -10,7 +10,7 @@
"@polkadot/extension-ui": "0.23.1"
},
"devDependencies": {
"@polkadot/dev": "^0.51.8",
"@polkadot/dev": "^0.51.9",
"@types/chrome": "^0.0.102",
"@types/firefox-webext-browser": "^70.0.1",
"babel-loader": "^8.1.0",
+376 -340
View File
File diff suppressed because it is too large Load Diff