Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.18.1
22.14.0
14 changes: 10 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ workaround).

A change is done when `yarn test`, `yarn typecheck` and `yarn lint` all pass.
CI runs the same three plus `yarn prepack` (bob build). Test files are covered
by typecheck and lint too.
by typecheck and lint too. `yarn typecheck` checks `src/` twice: against the
dev dependencies (Reanimated 2.12), then through the example app's peers
(Reanimated 3), so it needs the example installed (`yarn bootstrap`). Code that
only fits one side's typings fails there.

## Conventions worth knowing

Expand All @@ -126,8 +129,11 @@ by typecheck and lint too.
excluded from the package, so test-only code lives in those directories.
- **Pinned React.** `react` 18.1.0, `react-native` 0.70.6; `react-test-renderer`
must equal the `react` version exactly.
- **Example app** (`example/`, Expo 47) has its own `node_modules`; install it
with `yarn bootstrap`. It consumes `src/` directly, so library edits show up
without a build.
- **Example app** (`example/`, Expo SDK 52: React 18.3, RN 0.76, Reanimated
3.16, Gesture Handler 2.20, New Architecture) has its own `node_modules`;
install it with `yarn bootstrap`. It runs in Expo Go for SDK 52. It consumes
`src/` directly, so library edits show up without a build, and it is where
the Reanimated 3 / New Architecture side of the two version targets can be
checked on a device (Jest runs the minimum peers).
- Commits follow Conventional Commits; releases go through `release-it`
(`yarn release` publishes to npm - only run it when asked).
12 changes: 12 additions & 0 deletions docs/backlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ instead of reaching the top or the bottom. Clamp to 0..1 instead.
or an empty string would be better. Whatever changes, `createFullSectionData`
must keep spreading unknown fields of `stickyHeaderIndicesWithData` through.

## Reanimated 3 / New Architecture

Found by running the example app on Expo SDK 52 (Reanimated 3.16, Gesture
Handler 2.20, New Architecture), closer to production than the dev
dependencies.

### A drag on the dots sometimes scrolls the list instead

Not confirmed. On the Android emulator, two of six drags on the dots bar,
right after scrolling the list, scrolled the list and did not open the section
list; the other four worked. Check it again before treating it as a bug.

## Performance

None of these grows memory over time: they cost CPU and short-lived garbage.
Expand Down
7 changes: 4 additions & 3 deletions docs/unit-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ mock: most of what a test needs is already there.
| --- | --- |
| `jest.config.js` | `@testing-library/react-native` preset (see below), `clearMocks: true`, and `transformIgnorePatterns` that let Babel compile `react-native-reanimated`, `react-native-gesture-handler`, `react-native-redash` and `@shopify/flash-list`. |
| `babel.config.js` | Adds `react-native-reanimated/plugin` in the `test` env only (see [Reanimated runs for real](#reanimated-runs-for-real)). The published `lib/` build does not use it. |
| `jest/environment.js` | Node test environment that makes `global.performance` writable. RN 0.70's `jest/setup.js` assigns it, which throws on Node >= 18. Without this file the whole suite fails on a modern local Node, even though CI (Node 16 via `.nvmrc`) passes. |
| `jest/environment.js` | Node test environment that makes `global.performance` writable. RN 0.70's `jest/setup.js` assigns it, which throws on Node >= 18. Without this file the whole suite fails on Node 18 and newer, which CI also runs (`.nvmrc`). |
| `jest/setup.js` | Runs before the framework: loads `react-native-gesture-handler/jestSetup`, mocks `NativeAnimatedHelper`, and defines `global.ReanimatedDataMock` (see below). |
| `jest/setupAfterEnv.js` | Runs after the framework: loads the `setimmediate` polyfill Reanimated needs, registers the RNTL matchers (`@testing-library/react-native/extend-expect`), and adds the global `afterEach` that ends fake timers (see [Determinism](#determinism)). |
| `jest/matchers.d.ts` | Makes the RNTL matcher types visible to `yarn typecheck`; the runtime registration above is invisible to `tsc`. |
Expand Down Expand Up @@ -337,8 +337,9 @@ The `react-native` preset mocks native components. Two things that matter here:
- Run: `yarn test <path/to/thing.test.tsx>` for one file, `yarn test` for
everything, `yarn test --coverage` for the report. `yarn typecheck` and
`yarn lint` for the static gates.
- Node: CI uses `.nvmrc` (16.x). Newer local Node versions work because of
`jest/environment.js`.
- Node: CI uses `.nvmrc` (22.x). The example app (React Native 0.76) does not
install on Node below 18, and CI installs it for `yarn typecheck`. The tests
run on Node 18+ because of `jest/environment.js`.
- `react-test-renderer` must be **exactly** the installed `react` version
(`18.1.0`) - `@testing-library/react-native` compares the two and throws
otherwise. Bump them together.
Expand Down
12 changes: 7 additions & 5 deletions example/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"expo": {
"slug": "example",
"name": "example",
"sdkVersion": "47.0.0",
"jsEngine": "hermes"
},
"name": "example"
}
"jsEngine": "hermes",
"newArchEnabled": true,
"experiments": {
"tsconfigPaths": false
}
}
}
2 changes: 1 addition & 1 deletion example/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = function (api) {
api.cache(true);

return {
// babel-preset-expo adds the Reanimated plugin when Reanimated is installed.
presets: ['babel-preset-expo'],
plugins: [
[
Expand All @@ -16,7 +17,6 @@ module.exports = function (api) {
},
},
],
'react-native-reanimated/plugin',
],
};
};
42 changes: 18 additions & 24 deletions example/metro.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const path = require('path');
const escape = require('escape-string-regexp');
const { getDefaultConfig } = require('@expo/metro-config');
const exclusionList = require('metro-config/src/defaults/exclusionList');
const { getDefaultConfig } = require('expo/metro-config');
const pak = require('../package.json');

const root = path.resolve(__dirname, '..');
Expand All @@ -10,29 +8,25 @@ const modules = Object.keys({
...pak.peerDependencies,
});

const defaultConfig = getDefaultConfig(__dirname);
const escape = (string) => string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');

module.exports = {
...defaultConfig,
const config = getDefaultConfig(__dirname);

projectRoot: __dirname,
watchFolders: [root],
// The library's source lives in the parent folder.
config.watchFolders = [root];

// We need to make sure that only one version is loaded for peerDependencies
// So we block them at the root, and alias them to the versions in example's node_modules
resolver: {
...defaultConfig.resolver,
// We need to make sure that only one version is loaded for peerDependencies
// So we block them at the root, and alias them to the versions in example's node_modules
config.resolver.blockList = [
...[].concat(config.resolver.blockList ?? []),
...modules.map(
(m) => new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
),
];

blacklistRE: exclusionList(
modules.map(
(m) =>
new RegExp(`^${escape(path.join(root, 'node_modules', m))}\\/.*$`)
)
),
config.resolver.extraNodeModules = modules.reduce((acc, name) => {
acc[name] = path.join(__dirname, 'node_modules', name);
return acc;
}, {});

extraNodeModules: modules.reduce((acc, name) => {
acc[name] = path.join(__dirname, 'node_modules', name);
return acc;
}, {}),
},
};
module.exports = config;
33 changes: 14 additions & 19 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,33 @@
"@react-native-community/hooks": "^2.8.1",
"@react-navigation/native": "^6.1.2",
"@react-navigation/stack": "^6.3.11",
"@shopify/flash-list": "1.4.0",
"@shopify/react-native-performance-lists-profiler": "^1.1.0",
"@shopify/flash-list": "1.7.3",
"@types/lodash": "^4.14.191",
"@types/react-native": "~0.70.9",
"@welldone-software/why-did-you-render": "^7.0.1",
"expo": "~47.0.8",
"expo-status-bar": "~1.4.2",
"expo": "~52.0.0",
"expo-status-bar": "~2.0.1",
"lodash": "^4.17.21",
"react": "18.1.0",
"react-dom": "18.1.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-fast-compare": "^3.2.0",
"react-native": "0.70.6",
"react-native-flipper": "^0.176.1",
"react-native-gesture-handler": "~2.8.0",
"react-native-reanimated": "~2.12.0",
"react-native": "0.76.9",
"react-native-gesture-handler": "~2.20.2",
"react-native-reanimated": "~3.16.1",
"react-native-redash": "^18.1.0",
"react-native-safe-area-context": "^4.4.1",
"react-native-web": "~0.18.9",
"typescript": "^4.6.3"
"react-native-safe-area-context": "4.12.0",
"react-native-screens": "~4.4.0",
"react-native-web": "~0.19.13",
"typescript": "^5.3.3"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@expo/webpack-config": "^0.17.2",
"@babel/core": "^7.25.2",
"@react-native-community/eslint-config": "^3.0.2",
"@types/react": "*",
"babel-loader": "^8.1.0",
"@types/react": "~18.3.12",
"babel-plugin-module-resolver": "^4.1.0",
"eslint": "^8.4.1",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.0.5"

},
"private": true,
"eslintConfig": {
Expand Down
16 changes: 3 additions & 13 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'react-native-gesture-handler';
import React from 'react';
import { ListsProfiler } from '@shopify/react-native-performance-lists-profiler';
import { Platform, UIManager } from 'react-native';

import { DebugContextProvider } from './Debug';
Expand All @@ -14,18 +13,9 @@ const App = () => {
}

return (
<ListsProfiler
onInteractive={(TTI) => {
console.log(`TTI in millis: ${TTI}`);
}}
onBlankArea={(offsetStart, offsetEnd) => {
console.log(`Blank area: ${Math.max(offsetStart, offsetEnd)}`);
}}
>
<DebugContextProvider>
<NavigationTree />
</DebugContextProvider>
</ListsProfiler>
<DebugContextProvider>
<NavigationTree />
</DebugContextProvider>
);
};

Expand Down
2 changes: 1 addition & 1 deletion example/src/memoryLeak/MemoryLeak.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Payload = { renderId: number; data: number[] };

let renders = 0;

type HermesStats = Record<string, number>;
type HermesStats = { js_allocatedBytes: number };
type HermesGlobal = {
gc?: () => void;
HermesInternal?: { getInstrumentedStats?: () => HermesStats };
Expand Down
11 changes: 9 additions & 2 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
"paths": {
"react-native-fast-scroll": [
"../src/index"
]
],
"react": ["./node_modules/@types/react"],
"react-native": ["./node_modules/react-native"],
"react-native-gesture-handler": [
"./node_modules/react-native-gesture-handler"
],
"react-native-reanimated": ["./node_modules/react-native-reanimated"],
"react-native-redash": ["./node_modules/react-native-redash"],
"@shopify/flash-list": ["./node_modules/@shopify/flash-list"]
},
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"esModuleInterop": true,
"importsNotUsedAsValues": "error",
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"lib": [
Expand Down
25 changes: 0 additions & 25 deletions example/webpack.config.js

This file was deleted.

Loading
Loading