zth / rescript-relay-router

MIT License
16 stars 3 forks source link

React memo dependency arrays should be exhaustive in Route.useIsRouteActive #26

Closed Kingdutch closed 2 years ago

Kingdutch commented 2 years ago

When calling React.memo the memoised value should change when any of the used values change. In the generated route modules the useIsRouteActive function uses React.memo based on the location and exact key but the exact key is not part of the arguments array. This means that if a user writes the following code:

let [exact, setExact] = useState(false);
let isActive = Route.useIsRouteActive(exact);

The isActive may not change in case the exact input is changed.

zth commented 2 years ago

👍