best practices cleanup chats code review
This commit is contained in:
parent
61f9add741
commit
b802bb01e6
@ -1,9 +1,10 @@
|
||||
import React, { createContext, useContext, useEffect, useState } from "react";
|
||||
import { Dimensions } from "react-native";
|
||||
|
||||
const OrientationContext = createContext();
|
||||
const OrientationContext = createContext<string | null>(null);
|
||||
|
||||
export const useOrientation = () => useContext(OrientationContext);
|
||||
export const useOrientation = (): string | null =>
|
||||
useContext(OrientationContext);
|
||||
|
||||
export const OrientationProvider = ({ children }) => {
|
||||
const [orientation, setOrientation] = useState(getOrientation());
|
||||
@ -18,10 +19,8 @@ export const OrientationProvider = ({ children }) => {
|
||||
setOrientation(getOrientation());
|
||||
};
|
||||
|
||||
const subscription = Dimensions.addEventListener(
|
||||
"change",
|
||||
updateOrientation,
|
||||
);
|
||||
const subscription = Dimensions.addChangeListener(updateOrientation);
|
||||
|
||||
return () => subscription.remove();
|
||||
}, []);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user