mirror of
https://github.com/plebbit/seedit.git
synced 2026-06-11 17:46:27 -04:00
perf(settings): use default value and inline fallback for dynamic strings, instead of useEffect
This commit is contained in:
@@ -107,7 +107,7 @@ const AddressSettings = () => {
|
||||
<input
|
||||
type='text'
|
||||
placeholder='address.eth'
|
||||
value={cryptoState.cryptoAddress}
|
||||
defaultValue={cryptoState.cryptoAddress || (account?.author?.shortAddress.includes('.') ? account.author.shortAddress : '')}
|
||||
onChange={(e) => setCryptoState((prevState) => ({ ...prevState, cryptoAddress: e.target.value }))}
|
||||
/>
|
||||
<button className={styles.infoButton} onClick={() => setShowCryptoAddressInfo(!showCryptoAddressInfo)}>
|
||||
|
||||
@@ -110,7 +110,7 @@ const ThemeSettings = () => {
|
||||
const DisplayNameSetting = () => {
|
||||
const { t } = useTranslation();
|
||||
const account = useAccount();
|
||||
const [displayName, setDisplayName] = useState(account?.author.displayName || '');
|
||||
const [displayName, setDisplayName] = useState(account?.author?.displayName || '');
|
||||
const [savedDisplayName, setSavedDisplayName] = useState(false);
|
||||
|
||||
const saveUsername = async () => {
|
||||
@@ -133,7 +133,7 @@ const DisplayNameSetting = () => {
|
||||
return (
|
||||
<div className={styles.displayNameSetting}>
|
||||
<div className={styles.usernameInput}>
|
||||
<input type='text' placeholder='My Name' value={displayName} onChange={(e) => setDisplayName(e.target.value)} />
|
||||
<input type='text' placeholder='My Name' value={displayName || account?.author?.displayName || ''} onChange={(e) => setDisplayName(e.target.value)} />
|
||||
<button className={styles.button} onClick={saveUsername}>
|
||||
{t('save')}
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user