forked from cerc-io/laconic-wallet
Use context for maintaining accounts state (#41)
* Use context for maintaining accounts state * Remove custom hook from context
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import React, { createContext, useState } from 'react';
|
||||
|
||||
import { AccountsState } from '../types';
|
||||
|
||||
const AccountsContext = createContext<{
|
||||
accounts: AccountsState;
|
||||
setAccounts: (account: AccountsState) => void;
|
||||
}>({
|
||||
accounts: { ethAccounts: [], cosmosAccounts: [] },
|
||||
setAccounts: () => {},
|
||||
});
|
||||
|
||||
const AccountsProvider = ({ children }: { children: any }) => {
|
||||
const [accounts, setAccounts] = useState<AccountsState>({
|
||||
ethAccounts: [],
|
||||
cosmosAccounts: [],
|
||||
});
|
||||
return (
|
||||
<AccountsContext.Provider value={{ accounts, setAccounts }}>
|
||||
{children}
|
||||
</AccountsContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export { AccountsContext, AccountsProvider };
|
||||
Reference in New Issue
Block a user