-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove redundant code, render button by permission
- Loading branch information
1 parent
b023884
commit 8b25df5
Showing
3 changed files
with
38 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/components/mouseoverText/MouseoverTextTotalTimeUpdater.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { useEffect } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { getMouseoverText } from '../../actions/mouseoverTextAction'; | ||
|
||
function MouseoverTextTotalTimeUpdater({ getMouseoverText, mouseoverText, onUpdate }) { | ||
useEffect(() => { | ||
getMouseoverText(); | ||
}, [getMouseoverText]); | ||
|
||
useEffect(() => { | ||
if (mouseoverText) { | ||
onUpdate(mouseoverText); // Call the onUpdate function to pass the mouseoverText value to the parent component | ||
} | ||
}, [mouseoverText, onUpdate]); | ||
|
||
return null; | ||
} | ||
|
||
const mapStateToProps = (state) => { | ||
return { | ||
mouseoverText: state?.mouseoverText?.[0]?.mouseoverText, | ||
}; | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch) => ({ | ||
getMouseoverText: () => dispatch(getMouseoverText()), | ||
}); | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(MouseoverTextTotalTimeUpdater); |