Skip to content

Commit 385f7ab

Browse files
author
vinogradov
committed
Introduce import/export approach
1 parent 40f50b9 commit 385f7ab

File tree

12 files changed

+27
-26
lines changed

12 files changed

+27
-26
lines changed

.eslintrc.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ module.exports = {
44
browser: true
55
},
66
rules: {
7-
'object-curly-spacing': ['error', 'never'],
8-
'comma-dangle': ['error', 'never'],
7+
'object-curly-spacing': ['off'],
8+
'comma-dangle': ['off'],
99
'max-len': ['error', 120],
1010
'react/jsx-filename-extension': ['off'],
11-
'max-lines': ['error', {max: 600, skipBlankLines: true, skipComments: true}]
11+
'max-lines': ['error', {max: 600, skipBlankLines: true, skipComments: true}],
12+
"import/prefer-default-export": ['off']
1213
}
1314
};

src/examples/react/__tests__/hello.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import renderer from 'react-test-renderer';
3-
import Hello from '../hello';
3+
import {Hello} from '../hello';
44

55
test('renders correctly', () => {
66
const tree = renderer.create(

src/examples/react/hello.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import * as React from 'react';
1+
import React from 'react';
22
import PropTypes from 'prop-types';
33
import './hello.css';
44

5-
export default class Hello extends React.Component {
5+
export class Hello extends React.Component {
66
constructor(props) {
77
super(props);
88
this.state = {toggle: true};

src/examples/react/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22
import * as ReactDOM from 'react-dom';
3-
import Hello from './hello';
3+
import {Hello} from './hello';
44

55
ReactDOM.render(
66
<Hello name="John" />,

src/examples/redux/separate-files-redux-actions/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import {createStore, applyMiddleware, combineReducers} from 'redux';
22
import createSagaMiddleware from 'redux-saga';
33
import 'regenerator-runtime/runtime'; // eslint-disable-line import/no-extraneous-dependencies
44
import logger from 'redux-logger';
5-
import reducer from './reducers';
6-
import sagas from './sagas';
5+
import {reducer} from './reducers';
6+
import {watchAction1} from './sagas';
77
import {action1} from './actions';
88

99
const sagaMiddleware = createSagaMiddleware();
@@ -12,6 +12,6 @@ const store = createStore(
1212
combineReducers({reducer}),
1313
applyMiddleware(sagaMiddleware, logger));
1414

15-
sagaMiddleware.run(sagas);
15+
sagaMiddleware.run(watchAction1);
1616

1717
store.dispatch(action1({value1: 1}));

src/examples/redux/separate-files-redux-actions/reducers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66

77
const INITIAL_STATE = {};
88

9-
export default handleActions({
9+
export const reducer = handleActions({
1010
[action1](state, {payload: {value1}}) {
1111
return {
1212
...state,

src/examples/redux/separate-files-redux-actions/sagas.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {take} from 'redux-saga/effects';
22
import {action1} from './actions';
33

4-
export default function* watchAction1() {
4+
export function* watchAction1() {
55
while (true) { // eslint-disable-line no-constant-condition
66
yield take(action1);
77
console.log('watchAction1 saga!'); // eslint-disable-line no-console

src/examples/redux/separate-files/counter.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import * as React from 'react';
1+
import React from 'react';
22
import {connect} from 'react-redux';
33
import PropTypes from 'prop-types';
4-
import mapStateToProps from './map-state';
4+
import {mapStateToProps} from './map-state';
55
import {incrementAction, decrementAction, decrementAsyncAction} from './actions';
66

7-
class Counter extends React.Component {
7+
class Counter$ extends React.Component {
88
constructor(props) {
99
super(props);
1010
this.onIncrementHandler = this.onIncrementHandler.bind(this);
@@ -36,9 +36,9 @@ class Counter extends React.Component {
3636
}
3737
}
3838

39-
Counter.propTypes = {
39+
Counter$.propTypes = {
4040
dispatch: PropTypes.func.isRequired,
4141
counter: PropTypes.number.isRequired
4242
};
4343

44-
export default connect(mapStateToProps)(Counter);
44+
export const Counter = connect(mapStateToProps)(Counter$);

src/examples/redux/separate-files/index.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import * as React from 'react';
2-
import * as ReactDOM from 'react-dom';
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
33
import {createStore, applyMiddleware} from 'redux';
44
import {Provider} from 'react-redux';
55
import createSagaMiddleware from 'redux-saga';
66
import 'regenerator-runtime/runtime'; // eslint-disable-line import/no-extraneous-dependencies
77
import logger from 'redux-logger';
8-
import reducers from './reducers';
9-
import Counter from './counter';
10-
import sagas from './sagas';
8+
import {reducers} from './reducers';
9+
import {Counter} from './counter';
10+
import {watchDecrementAsync} from './sagas';
1111

1212
const sagaMiddleware = createSagaMiddleware();
1313

1414
const store = createStore(
1515
reducers,
1616
applyMiddleware(sagaMiddleware, logger));
1717

18-
sagaMiddleware.run(sagas);
18+
sagaMiddleware.run(watchDecrementAsync);
1919

2020
ReactDOM.render(
2121
<Provider store={store}>

src/examples/redux/separate-files/map-state.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function mapStateToProps(state) {
1+
export function mapStateToProps(state) {
22
return {
33
counter: state
44
};

src/examples/redux/separate-files/reducers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {INCREMENT_ACTION, DECREMENT_ACTION} from './actions';
22

33
const INITIAL_STATE = 0;
44

5-
export default function rootReducer(state = INITIAL_STATE, action) {
5+
export function reducers(state = INITIAL_STATE, action) {
66
const STEP = 1;
77

88
switch (action.type) {

src/examples/redux/separate-files/sagas.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function* decrementAsync() {
1616
yield put(actions.decrementAction());
1717
}
1818

19-
export default function* watchDecrementAsync() {
19+
export function* watchDecrementAsync() {
2020
while (true) { // eslint-disable-line no-constant-condition
2121
yield take(actions.DECREMENT_ASYNC_ACTION);
2222
yield call(decrementAsync);

0 commit comments

Comments
 (0)