Skip to content

Commit

Permalink
Introduce import/export approach
Browse files Browse the repository at this point in the history
  • Loading branch information
vinogradov committed Aug 2, 2017
1 parent 40f50b9 commit 385f7ab
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 26 deletions.
7 changes: 4 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ module.exports = {
browser: true
},
rules: {
'object-curly-spacing': ['error', 'never'],
'comma-dangle': ['error', 'never'],
'object-curly-spacing': ['off'],
'comma-dangle': ['off'],
'max-len': ['error', 120],
'react/jsx-filename-extension': ['off'],
'max-lines': ['error', {max: 600, skipBlankLines: true, skipComments: true}]
'max-lines': ['error', {max: 600, skipBlankLines: true, skipComments: true}],
"import/prefer-default-export": ['off']
}
};
2 changes: 1 addition & 1 deletion src/examples/react/__tests__/hello.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import renderer from 'react-test-renderer';
import Hello from '../hello';
import {Hello} from '../hello';

test('renders correctly', () => {
const tree = renderer.create(
Expand Down
4 changes: 2 additions & 2 deletions src/examples/react/hello.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import './hello.css';

export default class Hello extends React.Component {
export class Hello extends React.Component {
constructor(props) {
super(props);
this.state = {toggle: true};
Expand Down
2 changes: 1 addition & 1 deletion src/examples/react/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import Hello from './hello';
import {Hello} from './hello';

ReactDOM.render(
<Hello name="John" />,
Expand Down
6 changes: 3 additions & 3 deletions src/examples/redux/separate-files-redux-actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {createStore, applyMiddleware, combineReducers} from 'redux';
import createSagaMiddleware from 'redux-saga';
import 'regenerator-runtime/runtime'; // eslint-disable-line import/no-extraneous-dependencies
import logger from 'redux-logger';
import reducer from './reducers';
import sagas from './sagas';
import {reducer} from './reducers';
import {watchAction1} from './sagas';
import {action1} from './actions';

const sagaMiddleware = createSagaMiddleware();
Expand All @@ -12,6 +12,6 @@ const store = createStore(
combineReducers({reducer}),
applyMiddleware(sagaMiddleware, logger));

sagaMiddleware.run(sagas);
sagaMiddleware.run(watchAction1);

store.dispatch(action1({value1: 1}));
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {

const INITIAL_STATE = {};

export default handleActions({
export const reducer = handleActions({
[action1](state, {payload: {value1}}) {
return {
...state,
Expand Down
2 changes: 1 addition & 1 deletion src/examples/redux/separate-files-redux-actions/sagas.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {take} from 'redux-saga/effects';
import {action1} from './actions';

export default function* watchAction1() {
export function* watchAction1() {
while (true) { // eslint-disable-line no-constant-condition
yield take(action1);
console.log('watchAction1 saga!'); // eslint-disable-line no-console
Expand Down
10 changes: 5 additions & 5 deletions src/examples/redux/separate-files/counter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react';
import React from 'react';
import {connect} from 'react-redux';
import PropTypes from 'prop-types';
import mapStateToProps from './map-state';
import {mapStateToProps} from './map-state';
import {incrementAction, decrementAction, decrementAsyncAction} from './actions';

class Counter extends React.Component {
class Counter$ extends React.Component {
constructor(props) {
super(props);
this.onIncrementHandler = this.onIncrementHandler.bind(this);
Expand Down Expand Up @@ -36,9 +36,9 @@ class Counter extends React.Component {
}
}

Counter.propTypes = {
Counter$.propTypes = {
dispatch: PropTypes.func.isRequired,
counter: PropTypes.number.isRequired
};

export default connect(mapStateToProps)(Counter);
export const Counter = connect(mapStateToProps)(Counter$);
12 changes: 6 additions & 6 deletions src/examples/redux/separate-files/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import React from 'react';
import ReactDOM from 'react-dom';
import {createStore, applyMiddleware} from 'redux';
import {Provider} from 'react-redux';
import createSagaMiddleware from 'redux-saga';
import 'regenerator-runtime/runtime'; // eslint-disable-line import/no-extraneous-dependencies
import logger from 'redux-logger';
import reducers from './reducers';
import Counter from './counter';
import sagas from './sagas';
import {reducers} from './reducers';
import {Counter} from './counter';
import {watchDecrementAsync} from './sagas';

const sagaMiddleware = createSagaMiddleware();

const store = createStore(
reducers,
applyMiddleware(sagaMiddleware, logger));

sagaMiddleware.run(sagas);
sagaMiddleware.run(watchDecrementAsync);

ReactDOM.render(
<Provider store={store}>
Expand Down
2 changes: 1 addition & 1 deletion src/examples/redux/separate-files/map-state.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default function mapStateToProps(state) {
export function mapStateToProps(state) {
return {
counter: state
};
Expand Down
2 changes: 1 addition & 1 deletion src/examples/redux/separate-files/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {INCREMENT_ACTION, DECREMENT_ACTION} from './actions';

const INITIAL_STATE = 0;

export default function rootReducer(state = INITIAL_STATE, action) {
export function reducers(state = INITIAL_STATE, action) {
const STEP = 1;

switch (action.type) {
Expand Down
2 changes: 1 addition & 1 deletion src/examples/redux/separate-files/sagas.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function* decrementAsync() {
yield put(actions.decrementAction());
}

export default function* watchDecrementAsync() {
export function* watchDecrementAsync() {
while (true) { // eslint-disable-line no-constant-condition
yield take(actions.DECREMENT_ASYNC_ACTION);
yield call(decrementAsync);
Expand Down

0 comments on commit 385f7ab

Please sign in to comment.