diff --git a/src/App.tsx b/src/App.tsx index 8023cc0..1d271d6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,10 +8,8 @@ import RightBar from "./components/RightBar"; function App() { const [isOpenTransfer, setOpenTransfer] = useState(false); - const [isOpenProfile, setOpenProfile] = useState(false); const [isPolish, setLanguage] = useState(true); const [text, setText] = useState(""); - const [anchorEl, setAnchorEl] = React.useState(null); return (
@@ -25,17 +23,8 @@ function App() { handleLanguage={(e) => { setLanguage(!isPolish); }} - handleProfile={(e) => { - setOpenProfile(!isOpenProfile); - setAnchorEl(e.currentTarget as HTMLElement); - }} - handleClose={(e) => { - setOpenProfile(!isOpenProfile); - }} isOpenTransfer={isOpenTransfer} - isOpenProfile={isOpenProfile} isPolish={isPolish} - anchorEl={anchorEl} /> void; - handleProfile: (e: React.MouseEvent) => void; - handleClose: (e: React.MouseEvent) => void; handleLanguage: (e: React.MouseEvent) => void; textChangeHandler: (e: React.ChangeEvent) => void; isOpenTransfer: boolean; - isOpenProfile: boolean; isPolish: boolean; + +} + +interface TopBarState { + isOpenProfile: boolean; anchorEl: null | HTMLElement; } -interface TopBarState {} - -export default class TopBar extends React.Component< - TopBarProps, - TopBarState -> { +export default class TopBar extends React.Component { constructor(props: TopBarProps) { super(props); this.handleProfile = this.handleProfile.bind(this); - this.handleClose = this.handleProfile.bind(this); + this.handleClose = this.handleClose.bind(this); this.handleLanguage = this.handleLanguage.bind(this); this.handleTransfer = this.handleTransfer.bind(this); + this.state = { + isOpenProfile: false, + anchorEl:null, + }; } handleChange(e: React.ChangeEvent) { @@ -49,11 +50,16 @@ export default class TopBar extends React.Component< } handleProfile(e: React.MouseEvent) { - this.props.handleProfile(e); + this.setState({ + isOpenProfile: !this.state.isOpenProfile, + anchorEl:e.currentTarget as HTMLElement, + }); } handleClose(e: React.MouseEvent) { - this.props.handleClose(e); + this.setState({ + isOpenProfile: !this.state.isOpenProfile, + }); } render() { @@ -98,11 +104,12 @@ export default class TopBar extends React.Component< src={User} onClick={this.handleProfile} /> - Profile