import React, { useState } from 'react'; import PropTypes from 'prop-types'; import { UserType } from './Types'; import UserInfo from './UserInfo'; import Avatar from './Avatar'; export function Friends({ user, ...rest }) { return ; } export function Readers({ user, ...rest }) { return ; } function Users(props) { const [user, setUser] = useState({ uid: 0, uname: props.user }); return ( { user[props.prop] && user[props.prop].map(user => ) } ); } Friends.propTypes = { user: PropTypes.string.isRequired }; Readers.propTypes = { user: PropTypes.string.isRequired }; Users.propTypes = { user: PropTypes.string.isRequired, prop: PropTypes.string.isRequired };