@@ -70,7 +70,6 @@ export const SimpleAddressInput = ({
7070 showErrors : boolean ;
7171} ) : React . ReactElement => {
7272 const [ address , setAddress ] = useState < string > ( '' ) ;
73- const onChangeAddress = useCallback ( ( address ) => setAddress ( address ) , [ ] ) ;
7473
7574 const [ currentNetworkPrefix , setCurrentNetworkPrefix ] = useState ( 'rin' ) ;
7675
@@ -85,13 +84,16 @@ export const SimpleAddressInput = ({
8584 address && showErrors ? inValidNetworkError || inValidAddressError : '' ;
8685
8786 // fake ENS Resolution
88- const getAddressFromDomain = ( ) =>
89- new Promise < string > ( ( resolve ) => {
90- setTimeout (
91- ( ) => resolve ( '0x83eC7B0506556a7749306D69681aDbDbd08f0769' ) ,
92- 2000
93- ) ;
94- } ) ;
87+ const getAddressFromDomain = useCallback (
88+ ( ) =>
89+ new Promise < string > ( ( resolve ) => {
90+ setTimeout (
91+ ( ) => resolve ( '0x83eC7B0506556a7749306D69681aDbDbd08f0769' ) ,
92+ 2000
93+ ) ;
94+ } ) ,
95+ [ ]
96+ ) ;
9597
9698 return (
9799 < div >
@@ -113,7 +115,7 @@ export const SimpleAddressInput = ({
113115 name = "address"
114116 placeholder = { 'Ethereum address' }
115117 address = { address }
116- onChangeAddress = { onChangeAddress }
118+ onChangeAddress = { setAddress }
117119 getAddressFromDomain = { getAddressFromDomain }
118120 hiddenLabel = { hiddenLabel }
119121 error = { error }
@@ -161,7 +163,6 @@ export const AddressInputWithENSResolution = (): React.ReactElement => {
161163 const [ address , setAddress ] = useState < string > ( '' ) ;
162164 const [ showError , setShowError ] = useState < boolean > ( false ) ;
163165 const [ error , setError ] = useState < string > ( '' ) ;
164- const onChangeAddress = useCallback ( ( address ) => setAddress ( address ) , [ ] ) ;
165166
166167 const [ customENSThrottleDelay , setCustomENSThrottleDelay ] = useState <
167168 number | undefined
@@ -213,7 +214,7 @@ export const AddressInputWithENSResolution = (): React.ReactElement => {
213214 address = { address }
214215 helperText = { 'Type safe.test to check ENS resolution!' }
215216 disabled = { ! customENSThrottleDelay }
216- onChangeAddress = { onChangeAddress }
217+ onChangeAddress = { setAddress }
217218 getAddressFromDomain = { getAddressFromDomain }
218219 customENSThrottleDelay = { customENSThrottleDelay }
219220 />
@@ -251,7 +252,6 @@ export const AddressInputWithENSResolution = (): React.ReactElement => {
251252
252253export const SafeAddressInputValidation = ( ) : React . ReactElement => {
253254 const [ address , setAddress ] = useState < string > ( '' ) ;
254- const onChangeAddress = useCallback ( ( address ) => setAddress ( address ) , [ ] ) ;
255255 const [ isValidSafeAddress , setIsValidSafeAddress ] = useState < boolean > ( false ) ;
256256 const [ showLoadingSpinner , setShowLoadingSpinner ] = useState < boolean > ( false ) ;
257257
@@ -296,7 +296,7 @@ export const SafeAddressInputValidation = (): React.ReactElement => {
296296 showNetworkPrefix = { false }
297297 error = { showError ? error : '' }
298298 address = { address }
299- onChangeAddress = { onChangeAddress }
299+ onChangeAddress = { setAddress }
300300 showLoadingSpinner = { showLoadingSpinner }
301301 InputProps = { {
302302 endAdornment : isValidSafeAddress && (
@@ -315,8 +315,7 @@ export const SafeAddressInputValidation = (): React.ReactElement => {
315315
316316export const AddressInputWithSimpleAddressValidation =
317317 ( ) : React . ReactElement => {
318- const [ address , setAddress ] = useState < string > ( '' ) ;
319- const onChangeAddress = useCallback ( ( address ) => setAddress ( address ) , [ ] ) ;
318+ const [ address , setAddress ] = useState < string > ( '0x123...' ) ;
320319 const [ hasError , setHasError ] = useState < boolean > ( ) ;
321320
322321 useEffect ( ( ) => {
@@ -334,7 +333,7 @@ export const AddressInputWithSimpleAddressValidation =
334333 networkPrefix = "rin"
335334 error = { hasError ? error : '' }
336335 address = { address }
337- onChangeAddress = { onChangeAddress }
336+ onChangeAddress = { setAddress }
338337 />
339338 { /* Address In the State */ }
340339 < StyledText > Address In the State:</ StyledText >
@@ -347,7 +346,6 @@ export const AddressInputWithoutPrefix = (): React.ReactElement => {
347346 const [ address , setAddress ] = useState < string > (
348347 '0x83eC7B0506556a7749306D69681aDbDbd08f0769'
349348 ) ;
350- const onChangeAddress = useCallback ( ( address ) => setAddress ( address ) , [ ] ) ;
351349
352350 return (
353351 < form noValidate autoComplete = "off" onSubmit = { onSubmit } >
@@ -356,7 +354,7 @@ export const AddressInputWithoutPrefix = (): React.ReactElement => {
356354 name = "address"
357355 placeholder = { 'Ethereum address' }
358356 address = { address }
359- onChangeAddress = { onChangeAddress }
357+ onChangeAddress = { setAddress }
360358 />
361359 { /* Address In the State */ }
362360 < StyledText > Address In the State:</ StyledText >
@@ -369,19 +367,18 @@ export const AddressInputLoading = (): React.ReactElement => {
369367 const [ address , setAddress ] = useState < string > (
370368 '0x83eC7B0506556a7749306D69681aDbDbd08f0769'
371369 ) ;
372- const onChangeAddress = useCallback ( ( address ) => setAddress ( address ) , [ ] ) ;
373370
374371 return (
375372 < form noValidate autoComplete = "off" onSubmit = { onSubmit } >
376373 < AddressInput
377374 label = "Address"
378375 name = "address"
379376 networkPrefix = "rin"
380- showNetworkPrefix = { false }
377+ showNetworkPrefix
381378 placeholder = { 'Ethereum address' }
382379 showLoadingSpinner
383380 address = { address }
384- onChangeAddress = { onChangeAddress }
381+ onChangeAddress = { setAddress }
385382 />
386383 </ form >
387384 ) ;
@@ -391,15 +388,14 @@ export const AddressInputWithAdornment = (): React.ReactElement => {
391388 const [ address , setAddress ] = useState < string > (
392389 '0x83eC7B0506556a7749306D69681aDbDbd08f0769'
393390 ) ;
394- const onChangeAddress = useCallback ( ( address ) => setAddress ( address ) , [ ] ) ;
395391
396392 return (
397393 < form noValidate autoComplete = "off" onSubmit = { onSubmit } >
398394 < AddressInput
399395 label = "Address"
400396 name = "address"
401397 networkPrefix = "rin"
402- showNetworkPrefix = { false }
398+ showNetworkPrefix
403399 showLoadingSpinner = { false }
404400 placeholder = { 'Ethereum address' }
405401 InputProps = { {
@@ -410,7 +406,7 @@ export const AddressInputWithAdornment = (): React.ReactElement => {
410406 ) ,
411407 } }
412408 address = { address }
413- onChangeAddress = { onChangeAddress }
409+ onChangeAddress = { setAddress }
414410 />
415411 </ form >
416412 ) ;
@@ -420,20 +416,19 @@ export const AddressInputDisabled = (): React.ReactElement => {
420416 const [ address , setAddress ] = useState < string > (
421417 '0x83eC7B0506556a7749306D69681aDbDbd08f0769'
422418 ) ;
423- const onChangeAddress = useCallback ( ( address ) => setAddress ( address ) , [ ] ) ;
424419
425420 return (
426421 < form noValidate autoComplete = "off" onSubmit = { onSubmit } >
427422 < AddressInput
428423 label = "Address"
429424 name = "address"
430425 networkPrefix = "rin"
431- showNetworkPrefix = { false }
426+ showNetworkPrefix
432427 showLoadingSpinner = { false }
433428 disabled
434429 placeholder = { 'Ethereum address' }
435430 address = { address }
436- onChangeAddress = { onChangeAddress }
431+ onChangeAddress = { setAddress }
437432 />
438433 </ form >
439434 ) ;
@@ -443,7 +438,6 @@ export const AddressInputWithErrors = (): React.ReactElement => {
443438 const [ address , setAddress ] = useState < string > (
444439 '0x83eC7B0506556a7749306D69681aDbDbd08f0769'
445440 ) ;
446- const onChangeAddress = useCallback ( ( address ) => setAddress ( address ) , [ ] ) ;
447441
448442 return (
449443 < form noValidate autoComplete = "off" onSubmit = { onSubmit } >
@@ -455,7 +449,7 @@ export const AddressInputWithErrors = (): React.ReactElement => {
455449 placeholder = { 'Ethereum address' }
456450 showLoadingSpinner = { false }
457451 address = { address }
458- onChangeAddress = { onChangeAddress }
452+ onChangeAddress = { setAddress }
459453 error = { 'Invalid Address' }
460454 />
461455 </ form >
0 commit comments