ArtistPage.js 767 B

1234567891011121314151617181920
  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: {artist, alpha:true}};
  11. const [state, dispatchBrowser] = useReducer(browserReducer, INIT);
  12. return (
  13. <>
  14. <h1>{artist}</h1><Link routeName="browser">Browse</Link>
  15. <AlbumList {...state} dispatch={dispatchBrowser} playerDispatch={dispatch} scrollRef={scrollRef} noTitle noArtist/>
  16. </>
  17. );
  18. }