I've created an example to demonstrate the issue:
https://github.com/kocsis1david/apm-route-bug
If you use the simple Route
, the number will increase when switching between paths, see this video. But if you replace Route
to ApmRoute
, the number will always be 1
. The ApmRoute
is already imported so it's easy to replace to it in the example.
The cause of the problem seems to be that hooks lose their states when the route is changed, and useState
will reset the counter
to its default value.