♻️ refactor <MobilePreferences /> to use hooks
This commit is contained in:
parent
3a596ec371
commit
b87a313e12
1 changed files with 11 additions and 17 deletions
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
import { connect } from 'react-redux';
|
import { connect, useSelector, useDispatch } from 'react-redux';
|
||||||
import { withRouter } from 'react-router';
|
import { withRouter } from 'react-router';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
@ -31,13 +31,17 @@ const SectionSubeader = styled.h3`
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
||||||
const MobilePreferences = (props) => {
|
const MobilePreferences = () => {
|
||||||
|
// Props
|
||||||
const {
|
const {
|
||||||
setTheme, setAutosave, setLinewrap, setTextOutput, setGridOutput, setSoundOutput, lineNumbers, lintWarning
|
theme, autosave, linewrap, textOutput, gridOutput, soundOutput, lineNumbers, lintWarning
|
||||||
} = props;
|
} = useSelector(state => state.preferences);
|
||||||
|
|
||||||
|
// Actions
|
||||||
const {
|
const {
|
||||||
theme, autosave, linewrap, textOutput, gridOutput, soundOutput, setLineNumbers, setLintWarning
|
setTheme, setAutosave, setLinewrap, setTextOutput, setGridOutput, setSoundOutput, setLineNumbers, setLintWarning,
|
||||||
} = props;
|
} = bindActionCreators({ ...PreferencesActions, ...IdeActions }, useDispatch());
|
||||||
|
|
||||||
|
|
||||||
const generalSettings = [
|
const generalSettings = [
|
||||||
{
|
{
|
||||||
|
@ -108,14 +112,4 @@ MobilePreferences.propTypes = {
|
||||||
setSoundOutput: PropTypes.func.isRequired,
|
setSoundOutput: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
export default withRouter(MobilePreferences);
|
||||||
...state.preferences,
|
|
||||||
});
|
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => bindActionCreators({
|
|
||||||
...PreferencesActions,
|
|
||||||
...IdeActions
|
|
||||||
}, dispatch);
|
|
||||||
|
|
||||||
|
|
||||||
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(MobilePreferences));
|
|
||||||
|
|
Loading…
Reference in a new issue