useRemap
Combine, map & mutate a new state from multiple sources.
STATUS: This component is in development.
- The prop-interface can change drastically for each update
- Semantic Versioning will not be honored (only patch-updates to the package)
- Consult the design team for usage
- As always: Your feedback is welcomed!
function useMyHook() {
// ... some prelude
return (
useRemap<InstaLobbyResponse, InstaLobby>(instaLobbyResponse, {
initialValue: {
ready: false,
games: [],
floors: [],
},
mapper: InstaMapper,
mutate: useCallback((draft) => {
draft.games.forEach((game) => {
game.isFavorite = !!instaFavorites.favorites?.find(
gameRef => gameRef === game.ref
);
});
draft.ready = true;
}, [instaFavorites]),
})
)
}