Skip to content

Commit 9083739

Browse files
committed
update react hooks & compiler
1 parent b69deeb commit 9083739

9 files changed

+426
-12
lines changed

eslint.config.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import eslint from '@eslint/js';
2-
import { FlatCompat } from '@eslint/eslintrc';
32
import tseslint from 'typescript-eslint';
43
import importPlugin from 'eslint-plugin-import';
54
import jsxA11y from 'eslint-plugin-jsx-a11y';
65
import react from 'eslint-plugin-react';
7-
8-
const compat = new FlatCompat();
6+
import reactHooks from 'eslint-plugin-react-hooks';
7+
import reactCompiler from 'eslint-plugin-react-compiler';
98

109
export default tseslint.config(
1110
{ ignores: ['dist/', 'website/'] },
@@ -15,7 +14,8 @@ export default tseslint.config(
1514
jsxA11y.flatConfigs.recommended,
1615
react.configs.flat.recommended,
1716
react.configs.flat['jsx-runtime'],
18-
...compat.extends('plugin:react-hooks/recommended'),
17+
reactHooks.configs['recommended-latest'],
18+
reactCompiler.configs.recommended,
1919
{
2020
settings: {
2121
'import/resolver': { typescript: true },

examples/08_comparison/src/ContextWithMemo.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable react-compiler/react-compiler */
2+
13
import {
24
createContext,
35
memo,

examples/08_comparison/src/ContextWithUseMemo.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable react-compiler/react-compiler */
2+
13
import { createContext, useContext, useReducer, useRef, useMemo } from 'react';
24
import type { Reducer } from 'react';
35

examples/08_comparison/src/NaiveContext.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable react-compiler/react-compiler */
2+
13
import {
24
createContext,
35
useContext,

examples/08_comparison/src/ReactTracked.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable react-compiler/react-compiler */
2+
13
import { useReducer, useRef, useEffect } from 'react';
24
import type { Reducer } from 'react';
35

examples/08_comparison/src/SplitContext.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable react-compiler/react-compiler */
2+
13
import {
24
createContext,
35
memo,

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
"eslint-plugin-import": "^2.31.0",
102102
"eslint-plugin-jsx-a11y": "^6.10.2",
103103
"eslint-plugin-react": "^7.37.4",
104-
"eslint-plugin-react-hooks": "^5.1.0",
104+
"eslint-plugin-react-compiler": "19.0.0-beta-decd7b8-20250118",
105+
"eslint-plugin-react-hooks": "5.2.0-canary-de1eaa26-20250124",
105106
"happy-dom": "^16.7.2",
106107
"immer": "^10.1.1",
107108
"npm-run-all": "^4.1.5",

pnpm-lock.yaml

+407-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/createTrackedSelector.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { createProxy, isChanged } from 'proxy-compare';
33

44
import { useAffectedDebugValue } from './utils.js';
55

6+
const condUseAffectedDebugValue = useAffectedDebugValue;
7+
68
const hasGlobalProcess = typeof process === 'object';
79

810
export const createTrackedSelector = <State>(
@@ -41,8 +43,7 @@ export const createTrackedSelector = <State>(
4143
);
4244
const state = useSelector(selector);
4345
if (hasGlobalProcess && process.env.NODE_ENV !== 'production') {
44-
// eslint-disable-next-line react-hooks/rules-of-hooks
45-
useAffectedDebugValue(state, affected);
46+
condUseAffectedDebugValue(state, affected);
4647
}
4748
const proxyCache = useMemo(() => new WeakMap(), []); // per-hook proxyCache
4849
return createProxy(state, affected, proxyCache);

0 commit comments

Comments
 (0)