|
1 | 1 | import React from 'react'; |
2 | 2 | import { bindActionCreators } from 'redux'; |
3 | | -import { connect } from 'react-redux'; |
| 3 | +import { connect, useSelector, useDispatch } from 'react-redux'; |
4 | 4 | import { withRouter } from 'react-router'; |
5 | 5 | import PropTypes from 'prop-types'; |
6 | 6 | import styled from 'styled-components'; |
@@ -31,13 +31,17 @@ const SectionSubeader = styled.h3` |
31 | 31 | `; |
32 | 32 |
|
33 | 33 |
|
34 | | -const MobilePreferences = (props) => { |
| 34 | +const MobilePreferences = () => { |
| 35 | + // Props |
35 | 36 | 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 |
38 | 41 | 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 | + |
41 | 45 |
|
42 | 46 | const generalSettings = [ |
43 | 47 | { |
@@ -108,14 +112,4 @@ MobilePreferences.propTypes = { |
108 | 112 | setSoundOutput: PropTypes.func.isRequired, |
109 | 113 | }; |
110 | 114 |
|
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