Skip to content

Commit b87a313

Browse files
committed
♻️ refactor <MobilePreferences /> to use hooks
1 parent 3a596ec commit b87a313

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

client/modules/Mobile/MobilePreferences.jsx

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { bindActionCreators } from 'redux';
3-
import { connect } from 'react-redux';
3+
import { connect, useSelector, useDispatch } from 'react-redux';
44
import { withRouter } from 'react-router';
55
import PropTypes from 'prop-types';
66
import styled from 'styled-components';
@@ -31,13 +31,17 @@ const SectionSubeader = styled.h3`
3131
`;
3232

3333

34-
const MobilePreferences = (props) => {
34+
const MobilePreferences = () => {
35+
// Props
3536
const {
36-
setTheme, setAutosave, setLinewrap, setTextOutput, setGridOutput, setSoundOutput, lineNumbers, lintWarning
37-
} = props;
37+
theme, autosave, linewrap, textOutput, gridOutput, soundOutput, lineNumbers, lintWarning
38+
} = useSelector(state => state.preferences);
39+
40+
// Actions
3841
const {
39-
theme, autosave, linewrap, textOutput, gridOutput, soundOutput, setLineNumbers, setLintWarning
40-
} = props;
42+
setTheme, setAutosave, setLinewrap, setTextOutput, setGridOutput, setSoundOutput, setLineNumbers, setLintWarning,
43+
} = bindActionCreators({ ...PreferencesActions, ...IdeActions }, useDispatch());
44+
4145

4246
const generalSettings = [
4347
{
@@ -108,14 +112,4 @@ MobilePreferences.propTypes = {
108112
setSoundOutput: PropTypes.func.isRequired,
109113
};
110114

111-
const mapStateToProps = state => ({
112-
...state.preferences,
113-
});
114-
115-
const mapDispatchToProps = dispatch => bindActionCreators({
116-
...PreferencesActions,
117-
...IdeActions
118-
}, dispatch);
119-
120-
121-
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(MobilePreferences));
115+
export default withRouter(MobilePreferences);

0 commit comments

Comments
 (0)