Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SortableJS error when audioLists prop is empty array #308

Closed
Karnak19 opened this issue Feb 15, 2021 · 1 comment
Closed

SortableJS error when audioLists prop is empty array #308

Karnak19 opened this issue Feb 15, 2021 · 1 comment

Comments

@Karnak19
Copy link
Contributor

Version

4.22.0

Description

With 4.22.0 version, when the audioLists prop is an empty array, it trigger an error from SortableJS (see current behavior)

Steps

function Player() {
  const [songList, setSongList] = useState([]);
  const { data: musics, isFetched } = useQuery('songs', getSongs);

  useEffect(() => {
    if (isFetched) {
      setSongList(
        musics.map((song) => {
          const [min, sec] = (song.duration || '2:10').split(':');

          return {
            name: song.title,
            musicSrc: song.s3_link,
            cover: song.album?.picture,
            singer: song.artist?.name,
            duration: +min * 60 + +sec,
          };
        })
      );
    }
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [musics]);

  return (
        {/* ...... */}
        {isFetched && (
          <ReactJkMusicPlayer
            audioLists={[...songList]}
          />
        )}
      {/* ...... */}
  );
}

Steps to Reproduce

Pass an empty array to the audioLists prop

Expected Behavior

Component mounting without crashing, even with the empty array

Current Behavior

Crashing app

System information

Comments

It was workin perfectly fine on 4.21.2

@github-actions
Copy link

Hello @Karnak19, This bug/feature has been fixed/done and will be released together with the next release.
你好 @Karnak19,这个bug/feature 已经修复/完成, 会在下个版本一起发布。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants