ArtistPage.js 842 B

123456789101112131415161718192021
  1. import { Link } from 'react-router5'
  2. import {useRouteNode} from 'react-router5'
  3. import {unslugify} from './utils'
  4. import {useReducer} from 'react';
  5. import AlbumList from './AlbumList';
  6. import {browserReducer, ALBUMS_EMPTY} from './Browser';
  7. export default function ArtistPage({dispatch, scrollRef}) {
  8. const { route } = useRouteNode('artist');
  9. const artist = unslugify(route.params.artist);
  10. const INIT = {albums: ALBUMS_EMPTY, error: false, filters: {categories: {artist},
  11. filter:''}};
  12. const [state, dispatchBrowser] = useReducer(browserReducer, INIT);
  13. return (
  14. <>
  15. <h1>{artist}</h1><Link routeName="browser">Browse</Link>
  16. <AlbumList {...state} dispatch={dispatchBrowser} playerDispatch={dispatch} scrollRef={scrollRef} noTitle noArtist/>
  17. </>
  18. );
  19. }