Permalink
Browse files

just react state, redux removed

  • Loading branch information...
davidchang committed Mar 3, 2018
1 parent 26777fb commit 69da59a5b7a3d161a0cde92aeac30e4342f25553
Showing with 58 additions and 146 deletions.
  1. +1 −3 package.json
  2. +2 −4 src/App.js
  3. +44 −0 src/WrappedApp.js
  4. +0 −18 src/actions.js
  5. +2 −12 src/index.js
  6. +0 −34 src/reducers.js
  7. +9 −75 yarn.lock
@@ -6,9 +6,7 @@
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-redux": "^5.0.6",
"react-scripts": "1.1.1",
"redux": "^3.7.2"
"react-scripts": "1.1.1"
},
"scripts": {
"predeploy": "npm run build",
@@ -1,6 +1,4 @@
import React from 'react';
import { connect } from 'react-redux';
import actions from './actions';

function App({
caughtPokemon,
@@ -11,7 +9,7 @@ function App({
}) {
return (
<section>
<h1>Pokedex in Redux</h1>
<h1>Pokedex in React state</h1>

<form>
<div>
@@ -63,4 +61,4 @@ function App({
);
}

export default connect(store => store, actions)(App);
export default App;
@@ -0,0 +1,44 @@
import React from 'react';
import Pokemon from './pokemon';
import App from './App.js';

export default class WrappedApp extends React.Component {
state = {
caughtPokemon: [],
pokemon: Pokemon,
searchTerm: '',
};

searchTermChanged = searchTerm => {
this.setState({ searchTerm });
};

markCaught = newlyCaughtPokemon => {
this.setState({
caughtPokemon: [...this.state.caughtPokemon, newlyCaughtPokemon],
});
};

filter(pokemon, searchTerm) {
return searchTerm
? Pokemon.filter(
pokemon =>
pokemon.name.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1,
)
: Pokemon;
}

render() {
const { caughtPokemon, pokemon, searchTerm } = this.state;

return (
<App
caughtPokemon={caughtPokemon}
pokemon={this.filter(pokemon, searchTerm)}
searchTerm={searchTerm}
markCaught={this.markCaught}
searchTermChanged={this.searchTermChanged}
/>
);
}
}

This file was deleted.

Oops, something went wrong.
@@ -1,15 +1,5 @@
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore } from 'redux';
import reducers from './reducers';
import App from './App';
import WrappedApp from './WrappedApp';

const store = createStore(reducers);

ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root'),
);
ReactDOM.render(<WrappedApp />, document.getElementById('root'));

This file was deleted.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 69da59a

Please sign in to comment.