Skip to content

Commit

Permalink
Remove redux and react-redux dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
moroshko committed Jan 8, 2017
1 parent 3547c7c commit d7da836
Show file tree
Hide file tree
Showing 21 changed files with 257 additions and 460 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright © 2016 Misha Moroshko
Copyright © 2017 Misha Moroshko

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styles from './Basic.less';
import React, { Component } from 'react';
import isMobile from 'ismobilejs';
import Link from 'Link/Link';
import Autosuggest from 'AutosuggestContainer';
import Autosuggest from 'Autosuggest';
import languages from './languages';
import { escapeRegexCharacters } from 'utils/utils';

Expand Down Expand Up @@ -89,6 +89,7 @@ export default class Basic extends Component {
renderSuggestion={renderSuggestion}
inputProps={inputProps}
focusInputOnSuggestionClick={focusInputOnSuggestionClick}
focusFirstSuggestion={true}
id="basic-example"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import isMobile from 'ismobilejs';
import match from 'autosuggest-highlight/match';
import parse from 'autosuggest-highlight/parse';
import Link from 'Link/Link';
import Autosuggest from 'AutosuggestContainer';
import Autosuggest from 'Autosuggest';
import people from './people';
import { escapeRegexCharacters } from 'utils/utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import theme from './theme.less';
import React, { Component } from 'react';
import isMobile from 'ismobilejs';
import Link from 'Link/Link';
import Autosuggest from 'AutosuggestContainer';
import Autosuggest from 'Autosuggest';
import languages from './languages';
import { escapeRegexCharacters } from 'utils/utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import theme from './theme.less';

import React, { Component } from 'react';
import Modal from 'react-modal';
import Autosuggest from 'AutosuggestContainer';
import Autosuggest from 'Autosuggest';
import countries from './countries';
import { escapeRegexCharacters } from 'utils/utils';

Expand Down
34 changes: 19 additions & 15 deletions demo/src/components/App/components/Header/Header.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
import styles from './Header.less';

import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import React, { Component } from 'react';
import fetch from 'isomorphic-fetch';
import Link from 'Link/Link';
import GitHub from 'GitHub/GitHub';
import { loadStargazers } from './redux';

const mapStateToProps = ({ header }) => ({
stargazers: header.stargazers
});
export default class Header extends Component {
constructor() {
super();

class Header extends Component {
static propTypes = {
stargazers: PropTypes.string.isRequired,
loadStargazers: PropTypes.func.isRequired
};
this.state = {
stargazers: '1481'
};
}

componentDidMount() {
this.props.loadStargazers();
fetch('https://api.github.com/repos/moroshko/react-autosuggest')
.then(response => response.json())
.then(response => {
if (response.stargazers_count) {
this.setState({
stargazers: String(response.stargazers_count)
});
}
});
}

render() {
const { stargazers } = this.props;
const { stargazers } = this.state;

return (
<div className={styles.container}>
Expand Down Expand Up @@ -61,5 +67,3 @@ class Header extends Component {
);
}
}

export default connect(mapStateToProps, { loadStargazers })(Header);
34 changes: 0 additions & 34 deletions demo/src/components/App/components/Header/redux.js

This file was deleted.

18 changes: 1 addition & 17 deletions demo/src/index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
import es6promise from 'es6-promise';
import React from 'react';
import { render } from 'react-dom';
import { combineReducers, createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { Provider } from 'react-redux';
import header from 'App/components/Header/redux';
import App from 'App/App';

es6promise.polyfill(); // Required, because `Promise` is undefined in IE.

const appReducer = combineReducers({
header
});

const store = applyMiddleware(thunk)(createStore)(appReducer);

const Demo = () => (
<Provider store={store}>
<App />
</Provider>
);

render(
<Demo />,
<App />,
document.getElementById('demo')
);
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
},
"dependencies": {
"react-autowhatever": "^7.0.0",
"react-redux": "^5.0.1",
"redux": "^3.6.0",
"shallow-equal": "^1.0.0"
},
"peerDependencies": {
Expand Down Expand Up @@ -66,7 +64,6 @@
"react-dom": "^15.4.1",
"react-modal": "^1.6.4",
"react-transform-hmr": "^1.0.4",
"redux-thunk": "^2.1.0",
"sinon": "^1.17.6",
"sinon-chai": "^2.8.0",
"style-loader": "^0.13.1",
Expand Down Expand Up @@ -99,7 +96,7 @@
"react-component"
],
"nyc": {
"statements": 96,
"statements": 95,
"branches": 91,
"functions": 100,
"lines": 95,
Expand Down
Loading

0 comments on commit d7da836

Please sign in to comment.