Grégoire Delattre bcadc48d5a Launch prettier with the --fix option
They've changed their default settings, this changes a lot of stuff in
our code base.
2020-04-01 17:55:34 +02:00

36 lines
796 B
JavaScript

import React, { useState, useEffect } from "react";
import PropTypes from "prop-types";
export const ShowMore = ({ children, id, inLibrary }) => {
const [display, setDisplay] = useState(!inLibrary);
useEffect(() => {
setDisplay(!inLibrary);
}, [id, inLibrary]);
if (!display) {
return (
<span>
<a
onClick={() => setDisplay(true)}
className="badge badge-pill badge-secondary clickable mb-1"
>
More options ...
</a>
</span>
);
}
return <React.Fragment>{children}</React.Fragment>;
};
ShowMore.propTypes = {
id: PropTypes.string,
inLibrary: PropTypes.bool.isRequired,
children: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
};
ShowMore.defaultProps = {
id: "",
inLibrary: false,
};