Open neil-marcellini opened 4 days ago
Triggered auto assignment to @twisterdotcom (Bug
), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.
@janicduplessis is going to take this one since he touched the code that prompted the error.
I will take this!
We are trying to migrate the MapView component from using the withOnyx HOC to the newer useOnyx hook.
The current implementation uses withOnyx, which is an older pattern for connecting components to Onyx data.
In this file: https://github.com/Expensify/App/blob/ba9af8f082e76fc7da666e7f128574761fa97012/src/components/MapView/MapView.website.tsx#L35
Add the useOnyx hook inside the MapView component to fetch the userLocation data.
Add this code inside the component to get userLocation:
const [userLocation] = useOnyx({
key: ONYXKEYS.USER_LOCATION,
});
Migrate MapView to useOnyx
NA
We need to remove the withOnyx and use const [userLocation] = useOnyx(ONYXKEYS. USER_LOCATION);
@Shahidullah-Muffakir proposal looks good if you want to take this over.
@Shahidullah-Muffakir proposal looks good if you want to take this over.
@janicduplessis ,Sure, I can submit a PR. Thank you.
I removed the userLocation from the props and fetched it from the Onyx store using the useOnyx hook. This change caused a TypeScript error because userLocation was still listed in the MapView props. You can see the relevant code here: MapView types.
To fix the error, I had to remove userLocation from the props types. However, these props types were also used in other files: MapViewImpl. Hence I changed withOnyx to useOnyx in all these files.
Since only MapViewProps was needed in the types file, I realized there was no need for the types.ts file in the MapView folder. Instead, we can directly import MapViewProps in the MapView components.
Here are the changes I made:
Migrated from withOnyx to useOnyx in three MapView components. Removed userLocation from the props types since it’s no longer needed. Deleted the types.ts file and directly imported MapViewProps.
Here is the PR:https://github.com/Expensify/App/pull/50443 Thank you.
Problem
Coming from this PR ES Lint changed files check is failing because we need to migrate to useOnyx
https://github.com/Expensify/App/pull/41242#issuecomment-2391981853
Solution
Do the migration
Issue Owner
Current Issue Owner: @janicduplessis