Skip to content

Commit df6eacb

Browse files
committed
fix code snippet
1 parent 96bf288 commit df6eacb

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/content/10/en/part10c.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -757,16 +757,14 @@ Note that accessing a context's value using the <em>useContext</em> hook only wo
757757
Accessing the <em>AuthStorage</em> instance with <em>useContext(AuthStorageContext)</em> is quite verbose and reveals the details of the implementation. Let's improve this by implementing a <em>useAuthStorage</em> hook in a <i>useAuthStorage.js</i> file in the <i>hooks</i> directory:
758758

759759
```javascript
760-
import { createContext } from 'react';
761-
import { useContext } from 'react';
762-
763-
const AuthStorageContext = createContext();
760+
import { useContext } from 'react';
761+
import AuthStorageContext from '../contexts/AuthStorageContext';
764762

765-
export const useAuthStorage = () => {
763+
const useAuthStorage = () => {
766764
return useContext(AuthStorageContext);
767765
};
768766

769-
export default AuthStorageContext;
767+
export default useAuthStorage;
770768
```
771769

772770
The hook's implementation is quite simple but it improves the readability and maintainability of the hooks and components using it. We can use the hook to refactor the <em>useSignIn</em> hook like this:

0 commit comments

Comments
 (0)