Skip to content

Commit 92c3f00

Browse files
author
Ayush Krishnatray
committed
adding selectors
1 parent de115a4 commit 92c3f00

File tree

8 files changed

+21
-15
lines changed

8 files changed

+21
-15
lines changed

package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"react-redux": "^7.1.3",
3636
"react-router-dom": "^5.1.2",
3737
"redux": "^4.0.5",
38-
"redux-saga": "^1.1.3"
38+
"redux-saga": "^1.1.3",
39+
"reselect": "^4.0.0"
3940
},
4041
"devDependencies": {
4142
"@babel/core": "^7.8.3",

src/containers/TestComponent/TestComponent.jsx

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
/** eslint-disable */
21
import { connect } from 'react-redux';
3-
// import { createStructuredSelector } from 'reselect';
2+
import { createStructuredSelector } from 'reselect';
43
import { onChange } from './actions';
54
import TestComponent from '../../components/TestComponent/TestComponent';
6-
// import { valueData } from './selectors';
5+
import { valueData } from './selectors';
76

8-
// const mapStateToProps = createStructuredSelector({
9-
// value: valueData,
10-
// });
11-
12-
const mapStateToProps = (state) => ({
13-
value: (state.value && state.value.data) || ''
7+
const mapStateToProps = createStructuredSelector({
8+
value: valueData
149
});
1510

1611
const mapDispatchToProps = (dispatch) => ({
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const valueData = state => (state.value && state.value.data) || '';

src/containers/TestComponent/test/TestComponent.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import TestComponent from '../TestComponent';
99
describe('TestComponent Test Suite', () => {
1010
const state = {
1111
value: {},
12-
onChange: jest.fn(),
12+
onChange: jest.fn()
1313
};
1414
const mockStore = configureMockStore();
1515
const store = mockStore(state);

src/containers/TestComponent/test/actions.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ describe('actions', () => {
66
const data = 'Finish docs';
77
const expectedAction = {
88
type: ON_CHANGE,
9-
data,
9+
data
1010
};
1111
expect(onChange(data)).toEqual(expectedAction);
1212
});

src/containers/TestComponent/test/reducer.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import reducer from '../reducer';
22
import { ON_CHANGE } from '../constants';
33

44
const state = {
5-
data: '',
5+
data: ''
66
};
77

88
describe('todos reducer', () => {
@@ -15,7 +15,7 @@ describe('todos reducer', () => {
1515
expect(
1616
reducer(state, {
1717
type: ON_CHANGE,
18-
data,
18+
data
1919
}),
2020
).toEqual({ data });
2121
});

webpack.config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ module.exports = {
2020
test: /\.(js|jsx)$/,
2121
use: ['babel-loader']
2222
},
23+
// node-sass provides binding for Node.js to LibSass, a Sass compiler.
24+
// sass-loader is a loader for Webpack for compiling SCSS/Sass files.
25+
// style-loader injects our styles into our DOM.
26+
// css-loader interprets @import and @url() and resolves them.
27+
// mini-css-extract-plugin extracts our CSS out of the JavaScript bundle into a separate file, essential for production builds.
2328
{
2429
test: /\.s(a|c)ss$/,
25-
exclude: /\.module.(s(a|c)ss)$/,
2630
loader: [
2731
isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
2832
{

0 commit comments

Comments
 (0)