Skip to content

Commit 23838f0

Browse files
committed
Fix issue where accounts array was replaced with null
1 parent 9e53a99 commit 23838f0

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

web/src/Accounts.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ export default function Accounts({ match }) {
1717
const [accounts, setAccounts] = React.useState([])
1818
React.useEffect(() => {
1919
API.get('/v1/getAccounts')
20-
.then(res => setAccounts(res.data.Accounts))
20+
.then(res => {
21+
if (res.data.Accounts) {
22+
setAccounts(res.data.Accounts)
23+
}
24+
})
2125
}, [])
2226

2327
const accountCreated = (...newAccounts) => {
@@ -68,15 +72,15 @@ export default function Accounts({ match }) {
6872
<p>Alternatively, import an OFX or QFX file downloaded from your institution.</p>
6973
</Col>
7074
</Row>
71-
{accounts ? accounts.map(a =>
75+
{accounts.map(a =>
7276
<Row key={a.AccountID}>
7377
<Col>{a.AccountDescription}</Col>
7478
<Col className="account-buttons">
7579
<Link to={`${match.url}/edit/${a.AccountID}`} className="btn btn-outline-secondary">Edit</Link>
7680
<Button variant="outline-danger" onClick={() => deleteAccount(a.AccountID)}>Delete</Button>
7781
</Col>
7882
</Row>
79-
) : null}
83+
)}
8084
<Row>
8185
<Col className="account-actions">
8286
<Link to={`${match.url}/direct-connect`} className="btn btn-primary add-direct">Add new Direct Connect</Link>

0 commit comments

Comments
 (0)