Skip to content

Commit 2fed546

Browse files
committed
Refactored SVG component to use a selector
1 parent 3320685 commit 2fed546

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/components/Svg.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import { connect } from 'react-redux';
4+
import getMode from '../selectors/getMode';
45
import { JS, SUN_OUTLINED, SUN_FILLED } from '../data/icons';
56

67
const SVG = ({ control, mode }) => {
@@ -29,6 +30,8 @@ SVG.propTypes = {
2930
mode: PropTypes.string.isRequired
3031
};
3132

32-
const mapStateToProps = ({ mode }) => ({ mode });
33+
const mapStateToProps = state => ({
34+
mode: getMode(state)
35+
});
3336

3437
export default connect(mapStateToProps)(SVG);

src/selectors/getMode.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const getMode = state => state.mode;
2+
3+
export default getMode;

0 commit comments

Comments
 (0)