Skip to content

Commit cf5a4ac

Browse files
authored
React Native Upgrade 0.68 (#403)
* chore: rn upgrade * fix: use virtualisedlist * build: bump node circleci
1 parent 9d80e4f commit cf5a4ac

File tree

4 files changed

+528
-416
lines changed

4 files changed

+528
-416
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 2
22
jobs:
33
build:
44
docker:
5-
- image: circleci/node:12.22.0
5+
- image: circleci/node:14.18.2
66
working_directory: /home/circleci/rosetta
77
steps:
88
- checkout

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"object-hash": "3.0.0"
2525
},
2626
"peerDependencies": {
27-
"react": "*",
28-
"react-native": "*"
27+
"react": "17.0.2",
28+
"react-native": "0.68.1"
2929
},
3030
"devDependencies": {
3131
"@babel/core": "7.17.5",
@@ -54,7 +54,7 @@
5454
"prettier": "2.6.0",
5555
"prettier-eslint": "13.0.0",
5656
"react": "17.0.2",
57-
"react-native": "0.67.3",
57+
"react-native": "0.68.1",
5858
"react-test-renderer": "17.0.2",
5959
"typescript": "4.4.4"
6060
},

src/node-view/node-view.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { ReactElement, useCallback, useEffect, useState } from 'react';
2-
import { FlatList, Pressable } from 'react-native';
2+
import { Pressable, VirtualizedList } from 'react-native';
33
import { useNodesContext } from '../nodes-context-provider';
44
import { INode } from './types';
55

@@ -31,7 +31,6 @@ const NodeView: React.FC<IProps> = React.memo(
3131
initialNumToRender,
3232
}) => {
3333
const { openedNodes, setOpenNode } = useNodesContext();
34-
3534
const [_node, setNode]: [INode, any] = useState({
3635
...node,
3736
opened:
@@ -85,6 +84,10 @@ const NodeView: React.FC<IProps> = React.memo(
8584
[renderChildren, level],
8685
);
8786

87+
const getItem = useCallback((data, index) => data && data[index], []);
88+
89+
const getItemCount = useCallback((data) => data?.length ?? 0, []);
90+
8891
const keyExtractor = useCallback((item: INode) => item._internalId, []);
8992

9093
const nodeChildrenName = getChildrenName(_node);
@@ -101,8 +104,10 @@ const NodeView: React.FC<IProps> = React.memo(
101104
</Pressable>
102105
) : null}
103106
{isNodeOpened && nodeChildren ? (
104-
<FlatList
107+
<VirtualizedList
105108
data={nodeChildren}
109+
getItemCount={getItemCount}
110+
getItem={getItem}
106111
renderItem={renderItem}
107112
extraData={extraData}
108113
keyExtractor={keyExtractor}

0 commit comments

Comments
 (0)