Skip to content

Commit 8d4ef27

Browse files
committed
Updates for FlashList v2
1 parent e91f8d7 commit 8d4ef27

File tree

23 files changed

+185
-113
lines changed

23 files changed

+185
-113
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plextv/react-lightning-plugin-flexbox": patch
3+
---
4+
5+
fix: Minor optimization

.changeset/old-lies-lick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plextv/react-native-lightning": patch
3+
---
4+
5+
fix(polyfill): Add missing dom functions needed by flashlist v2

.changeset/tasty-bears-hang.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@plextv/react-native-lightning-components": patch
3+
"@plextv/react-native-lightning-example": patch
4+
"@plextv/react-lightning-storybook": patch
5+
---
6+
7+
feat(FlashList): Update FlashList to v2.2.0

apps/react-native-lightning-example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@plextv/vite-plugin-react-native-lightning": "workspace:*",
4343
"@plextv/vite-plugin-react-reanimated-lightning": "workspace:*",
4444
"@repo/configs": "workspace:*",
45-
"@shopify/flash-list": "1.8.3",
45+
"@shopify/flash-list": "2.2.0",
4646
"@types/react": "19.2.2",
4747
"@types/react-dom": "19.2.2",
4848
"@vitejs/plugin-legacy": "7.2.1",

apps/react-native-lightning-example/src/pages/FlashListTest.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export const FlashListTest: FC = () => {
3838
{item}
3939
</ScrollItem>
4040
)}
41-
estimatedItemSize={75}
4241
drawDistance={75}
4342
snapToAlignment="center"
4443
/>
@@ -66,7 +65,6 @@ export const FlashListTest: FC = () => {
6665
{item}
6766
</ScrollItem>
6867
)}
69-
estimatedItemSize={75}
7068
drawDistance={75}
7169
snapToAlignment="center"
7270
/>

apps/storybook/src/react-native-lightning-components/lists/FlashList.stories.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export const FlashListExample = () => {
4747
{item}
4848
</ScrollItem>
4949
)}
50-
estimatedItemSize={50}
5150
drawDistance={50}
5251
/>
5352
</View>
@@ -76,7 +75,6 @@ export const FlashListExample = () => {
7675
{item}
7776
</ScrollItem>
7877
)}
79-
estimatedItemSize={50}
8078
drawDistance={50}
8179
/>
8280
</View>

packages/plugin-flexbox/src/LightningManager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@ export class LightningManager {
142142
if (el.parent?.style.display !== 'flex') {
143143
skipX =
144144
el.style.x !== undefined &&
145+
el.rawProps.style?.x !== undefined &&
145146
el.style.transform?.translateX === undefined;
146147
skipY =
147148
el.style.y !== undefined &&
149+
el.rawProps.style?.y !== undefined &&
148150
el.style.transform?.translateY === undefined;
149151
}
150152

packages/plugin-flexbox/src/YogaManager.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,12 @@ describe('YogaManager', () => {
366366
expect(applyReactPropsToYoga).toHaveBeenCalledWith(
367367
mockYoga,
368368
mockYogaOptions,
369-
mockNode,
369+
{
370+
children: [],
371+
id: elementId,
372+
node: mockNode,
373+
props: {},
374+
},
370375
style,
371376
);
372377
});

packages/plugin-flexbox/src/YogaManager.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { LightningElementStyle, Rect } from '@plextv/react-lightning';
22
import { EventEmitter } from 'tseep';
3-
import { type Config, loadYoga, type Node, type Yoga } from 'yoga-layout/load';
3+
import { type Config, loadYoga, type Yoga } from 'yoga-layout/load';
4+
import type { ManagerNode } from './types/ManagerNode';
45
import type { YogaOptions } from './types/YogaOptions';
56
import applyReactPropsToYoga, {
67
applyFlexPropToYoga,
@@ -9,13 +10,6 @@ import { SimpleDataView } from './util/SimpleDataView';
910

1011
export type BatchedUpdate = Record<number, Partial<Rect>>;
1112

12-
type ManagerNode = {
13-
id: number;
14-
parent?: ManagerNode;
15-
node: Node;
16-
children: ManagerNode[];
17-
};
18-
1913
export type YogaManagerEvents = {
2014
// Updates are sent in an array. This is because when working with web
2115
// workers, it's more efficient to transfer an array instead of serializing
@@ -234,7 +228,7 @@ export class YogaManager {
234228
return;
235229
}
236230

237-
applyReactPropsToYoga(this._yoga, this._yogaOptions, yogaNode.node, style);
231+
applyReactPropsToYoga(this._yoga, this._yogaOptions, yogaNode, style);
238232

239233
if (style.transform) {
240234
const { x, y, transform } = style;
@@ -337,6 +331,7 @@ export class YogaManager {
337331
id: elementId,
338332
node,
339333
children: [],
334+
props: {},
340335
};
341336

342337
this._elementMap.set(elementId, yogaNode);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Node } from 'yoga-layout';
2+
3+
export type ManagerNode = {
4+
id: number;
5+
parent?: ManagerNode;
6+
node: Node;
7+
children: ManagerNode[];
8+
props: Record<string, unknown>;
9+
};

0 commit comments

Comments
 (0)