import React, { useState, useEffect } from "react"; import { connect } from "react-redux"; import * as actions from "../constants/actions/index"; import store from "../store"; import Library from "./Library"; import { Spin } from "antd"; import Player from "./Player"; import { findMyPlaylists, createMyPlaylist } from "../actions/playerActions"; import Header from "./Header"; import Footer from "./Footer"; import "../styles/library.css"; import "../styles/playlists.css"; import "../styles/MyPlaylists.css"; const MyPlaylists = ({ createMyPlaylist, findMyPlaylists, showMyPlaylists = [], }) => { const [playlistName, setPlaylistName] = useState(""); const [buttonClick, setButtonClick] = useState(false); console.log("showMyPlaylists in MyPlaylists: ", showMyPlaylists); // let owner = localStorage.user; // let id = localStorage.id; // uploadTrack.onsubmit = async (e) => { // e.preventDefault(); // let response = await fetch('/article/formdata/post/user-avatar', { // method: 'POST', // body: new FormData(formElem) // }); // let result = await response.json(); // alert(result.message); // }; useEffect(() => { findMyPlaylists() }, [buttonClick]);//вызывая функцию findMyPlaylists через useEffect можно получить ошибку при переходе из страницы мои плейлисты на страницу все плейлисты return ( <>
{!showMyPlaylists.length && (
)}

My playlists

    {showMyPlaylists.map((playlist, item) => (
  • {playlist.name}
  • ))}
setPlaylistName(e.target.value)} />

Add track