Using React.memo to improve render performance of KanjiListCell

master
Arthur VALIN 2 years ago
parent b29d6a7d57
commit 275f265fbb

Binary file not shown.

@ -1,6 +1,7 @@
{ {
"ExpandedNodes": [ "ExpandedNodes": [
"", "",
"\\assets",
"\\components", "\\components",
"\\model", "\\model",
"\\navigation", "\\navigation",
@ -10,6 +11,6 @@
"\\redux\\reducers", "\\redux\\reducers",
"\\redux\\thunks" "\\redux\\thunks"
], ],
"SelectedNode": "\\components\\KanjiCard.tsx", "SelectedNode": "\\components\\DrawingCanva.tsx",
"PreviewInSolutionExplorer": false "PreviewInSolutionExplorer": false
} }

Binary file not shown.

@ -120,7 +120,12 @@ const style_light = StyleSheet.create({
slider: { slider: {
width: "75%", width: "75%",
alignSelf: "center", alignSelf: "center",
} },
visibility: {
position: "absolute",
right: 50,
top: -25
}
}); });
const style_dark = StyleSheet.create({ const style_dark = StyleSheet.create({

@ -75,6 +75,8 @@ const KanjiCard = (props: KanjiProps) => {
showsVerticalScrollIndicator={false}> showsVerticalScrollIndicator={false}>
<Text style={kanjiCardStyle.text}>{kanji?.onyomi}</Text> <Text style={kanjiCardStyle.text}>{kanji?.onyomi}</Text>
<Text style={kanjiCardStyle.text}>{kanji?.kunyomi}</Text>
<SvgXml <SvgXml
xml={imgXml xml={imgXml
.replace(/fill="#[0-9a-f]{6}"/g, `fill=${kanjiCardStyle.svg.color}`)} .replace(/fill="#[0-9a-f]{6}"/g, `fill=${kanjiCardStyle.svg.color}`)}

@ -43,6 +43,7 @@ const KanjiList = () => {
{selectedItems.length ? {selectedItems.length ?
(<SectionList (<SectionList
sections={selectedItems} sections={selectedItems}
windowSize={100}
renderItem={ renderItem={
({ item }) => <KanjiListCell kanji={item} /> ({ item }) => <KanjiListCell kanji={item} />
} }

@ -7,7 +7,7 @@ interface kanjiListCellProps {
kanji: Kanji; kanji: Kanji;
} }
const KanjiListCell = (props: kanjiListCellProps) => { const KanjiListCell = React.memo((props: kanjiListCellProps) => {
const cellStyle = useColorScheme() == 'light' ? cellStyle_light : cellStyle_dark; const cellStyle = useColorScheme() == 'light' ? cellStyle_light : cellStyle_dark;
@ -19,7 +19,7 @@ const KanjiListCell = (props: kanjiListCellProps) => {
<Text style={cellStyle.text}>{props.kanji.meaning}</Text> <Text style={cellStyle.text}>{props.kanji.meaning}</Text>
</TouchableOpacity> </TouchableOpacity>
); );
}; });
const cellStyle_light = StyleSheet.create({ const cellStyle_light = StyleSheet.create({
item: { item: {

@ -118,6 +118,10 @@ const TabBar = () => {
); );
} }
const tabOptions: BottomTabNavigationOptions = { const tabOptions: BottomTabNavigationOptions = {
tabBarShowLabel: false, tabBarShowLabel: false,
headerShown: false, headerShown: false,

Loading…
Cancel
Save