From 6ac382b65912c36219c9a838705d6ad4c89aefaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Delattre?= Date: Fri, 3 Apr 2020 16:19:12 +0200 Subject: [PATCH] Use redux hooks on buttons components --- frontend/js/components/buttons/torrents.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/js/components/buttons/torrents.js b/frontend/js/components/buttons/torrents.js index 94c3d2d..07da703 100644 --- a/frontend/js/components/buttons/torrents.js +++ b/frontend/js/components/buttons/torrents.js @@ -1,7 +1,7 @@ import React, { useState } from "react"; import PropTypes from "prop-types"; import { List } from "immutable"; -import { connect } from "react-redux"; +import { useDispatch } from "react-redux"; import { prettySize } from "../../utils"; import { addTorrent } from "../../actions/torrents"; @@ -45,10 +45,10 @@ function buildMenuItems(torrents) { return entries; } -const torrentsButton = ({ torrents, search, searching, addTorrent, url }) => { - /* eslint-disable */ +export const TorrentsButton = ({ torrents, search, searching, url }) => { + const dispatch = useDispatch(); + const [show, setShow] = useState(false); - /* eslint-enable */ const entries = buildMenuItems(torrents); const count = torrents && torrents.size !== 0 ? torrents.size : 0; @@ -97,7 +97,10 @@ const torrentsButton = ({ torrents, search, searching, addTorrent, url }) => { return ; case "entry": return ( - addTorrent(e.url)}> + dispatch(addTorrent(e.url))} + > {e.quality} {e.size !== 0 && ( ({prettySize(e.size)}) @@ -111,15 +114,12 @@ const torrentsButton = ({ torrents, search, searching, addTorrent, url }) => { ); }; -torrentsButton.propTypes = { +TorrentsButton.propTypes = { torrents: PropTypes.instanceOf(List), searching: PropTypes.bool, search: PropTypes.func.isRequired, - addTorrent: PropTypes.func.isRequired, url: PropTypes.string, }; -torrentsButton.defaultProps = { +TorrentsButton.defaultProps = { torrents: List(), }; - -export const TorrentsButton = connect(null, { addTorrent })(torrentsButton);