Bug: Rules of hooks does not check children function of component rendered within a Class Component

This issue has been created since 2022-11-09.

React version:

Steps To Reproduce

  1. Create a class component
  2. In the render function, return a component that expects a function as a child
  3. Define the child function in-line, and call a React hook or custom hook within that child.

Link to code example: https://codesandbox.io/s/bold-grass-teutjm?file=/src/TestComponent.tsx

The current behavior

There is no rules-of-hooks violation on this hook usage, even though it clearly violates the rules of hooks.

The expected behavior

The callsite of the hook should be flagged as a violation of the rules of hooks.

TomDo1234 wrote this answer on 2022-11-11

I have managed to replicate this bug here https://github.com/TomDo1234/ReactHookRuleBug

More Details About Repo
Owner Name facebook
Repo Name react
Full Name facebook/react
Language JavaScript
Created Date 2013-05-24
Updated Date 2022-12-10
Star Count 198882
Watcher Count 6638
Fork Count 41302
Issue Count 1120

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Migration from DAPInstall.nvim 12 2022-04-21 2022-11-20
Iterators can't be copied 1 2021-10-09 2022-04-05
BTreeMap<String, Value> for add_map 5 2021-08-27 2022-04-05
Can't connect - getting ShopifyException: (401 Unauthorized) [API] Invalid API key or access token (unrecognized login or wrong password) 3 2022-06-13 2022-07-30
Updating Product Variant Price is read-only 5 2022-06-02 2022-07-30
Highligth n_grams index error 3 2021-11-10 2022-11-19
TypeError: Cannot read property 'filter' of undefined 1 2021-06-29 2022-11-01
tl/dr, could this be changed around to work for valorant? 2 2021-11-03 2021-12-26
ErrorException in GET /assets/1/edit 0 2022-05-15 2022-09-16
[Question] Can you please provide an example? 4 2022-07-19 2022-11-05
Configurable `User-Agent` for `HTTP::Client` 0 2022-09-29 2022-10-04
able to select one object to clear like trees 2 2022-08-04 2022-10-07
Permintaan fitur: Sering terjadi Folder desa yang kurang sehingga upload tidak dapat dilakukan 2 2022-06-16 2022-10-22
Latejoin professions window don't want automatically close itself 1 2021-10-18 2022-10-12
Vim mech unable to be entered. 1 2021-10-18 2022-09-27
Document how `let` treats macros 9 2017-11-02 2022-11-22
No Autofill with Tumblr (and other apps) 2 2021-08-06 2022-10-07
performance of SECOND on Waymo 7 2022-02-03 2022-10-28
Track 'Mulberry' 0 2021-09-05 2022-01-10
@types/[email protected] type definition build failed 2 2021-07-17 2022-08-18
pgSQL & Redis external - Error executing 'postInstallation': Files to substitute resolved to an empty list 8 2021-04-28 2022-12-03
Document Authentication 6 2021-01-16 2022-11-16
enhance page to edit OAUTH token 0 2022-09-19 2022-10-25
[Rust] Provide a blanket impl of ToPolar for &ToPolar 0 2022-06-12 2022-12-03
Failing unit tests due to international decimal parsing 0 2022-04-19 2022-12-09
【工具推荐】在线网站图标快速设计生成工具 0 2022-08-02 2022-09-19
requestCreateControls fails silently in case of invalid JSON schema 1 2022-09-19 2022-10-30
Should create the same verison with AKS while enabling Virtual Node.. 6 2021-11-03 2022-12-10
Disable autocompletion when moving through command history (after up or down arrows) 3 2021-12-15 2022-09-24
feature request: double tap to insert `tab` 2 2021-06-21 2022-10-15
`danger pr` treats GitLab URLs as GitHub and fails 2 2022-09-26 2022-11-16
Return type of ViTFeatureExtractor does not match 'return_tensors' parameter when input is torch.Tensor or PIL.Image.Image 3 2022-01-06 2022-08-23
Link to Designer's site in README.md 2 2021-11-10 2022-11-09
disable caliper-fabric-gateway-enabled in 4.2 version 0 2022-03-13 2022-09-30
disable caliper-fabric-gateway-enabled in 4.2 version 12 2022-03-13 2022-09-29
demo ftp 文件夹下载失败。 1 2021-03-18 2021-12-26
UBIF-0018 Map zooms to incorrect level when importing data 0 2019-06-08 2022-12-02
feat(ingest): Add a business glossary source 0 2021-08-27 2022-08-11
[Feature] IPage to support getting the cookies applicable to the open page 1 2022-01-12 2022-01-07
In line debugger - can't connect through websocket 1 2020-10-12 2022-11-07
translate_list_glossary: should list glossaries in project failed 0 2022-09-17 2022-11-30
Multiple open trades with same pair (position stacking) 3 2018-07-30 2022-11-24
PhysicsSim doesn't work with init_velocities 2 2018-03-18 2022-11-02
Client Allocation Request for: MikaeLa 2 2022-09-07 2022-10-07
WSGI Apache Reload Error, Need Correct Format for Apache Conf file 4 2018-11-05 2022-11-21
Got this error after execute command 'minikube delete' and run again 'minikube start --driver=docker' 3 2022-01-26 2022-10-29
Improvement for k8s.io/docs/tasks/debug-application-cluster/debug-running-pod/ 2 2022-02-26 2022-12-09
RabbitTemplate is not fully data safe 10 2022-11-28 2022-12-03
Fix Documentation For Containers with Zero Queues 0 2022-11-28 2022-12-03
how to check Mac Address to local network wifi 2 2022-10-23 2022-11-20