-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache system color scheme, fix memoised ChatToJsx.
This commit improves performance considerably when there's lots of Text. - useColorScheme seems to cause unnecessary performance lag, and is called everytime Text is invoked. It is now only called once globally for the entire application, and passed via React context. - Memoising ChatToJsx properly reduces CPU load from chat parsing. ChatToJsx is no longer improperly memoised by default, and the item renderer in ChatScreen is memoised correctly instead.
- Loading branch information
Showing
4 changed files
with
104 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
import { useContext } from 'react' | ||
import { useColorScheme } from 'react-native' | ||
import SettingsContext from '../context/settingsContext' | ||
import { createContext, useContext } from 'react' | ||
|
||
const useDarkMode = () => { | ||
const colorScheme = useColorScheme() | ||
const { settings } = useContext(SettingsContext) | ||
const systemDefault = colorScheme === null ? true : colorScheme === 'dark' | ||
return settings.darkMode === null ? systemDefault : settings.darkMode | ||
} | ||
export const ColorSchemeContext = createContext<boolean>(false) | ||
|
||
const useDarkMode = () => useContext(ColorSchemeContext) | ||
|
||
export default useDarkMode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters