-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup redux reducers, actions, and store. Also moved App to component…
…s folder
- Loading branch information
1 parent
aeea5ac
commit 4162a3c
Showing
10 changed files
with
11,043 additions
and
6 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const ACTIONS = { | ||
REPLACE_MOVIES: "REPLACE_MOVIES", | ||
CHANGE_SELECTED: "CHANGE_SELECTED" | ||
}; | ||
|
||
export default ACTIONS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import './index.css'; | ||
import App from './App'; | ||
import registerServiceWorker from './registerServiceWorker'; | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import "./index.css"; | ||
import App from "./components/App"; | ||
import registerServiceWorker from "./registerServiceWorker"; | ||
import { Provider } from "react-redux"; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); | ||
import store from "./redux/store"; | ||
|
||
ReactDOM.render( | ||
<Provider store={store}> | ||
<App /> | ||
</Provider>, | ||
document.getElementById("root") | ||
); | ||
registerServiceWorker(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import ACTIONS from "../../constants"; | ||
|
||
const replaceMovies = newMovies => ({ | ||
type: ACTIONS.REPLACE_MOVIES, | ||
newMovies | ||
}); | ||
|
||
const changeSelected = newSelected => ({ | ||
type: ACTIONS.CHANGE_SELECTED, | ||
newSelected | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import ACTIONS from "../../constants/actions"; | ||
|
||
const initialState = { | ||
movies: [], | ||
selected: "" | ||
}; | ||
|
||
/* Main reducer. */ | ||
const reducer = (state = initialState, action) => { | ||
switch (action.type) { | ||
case ACTIONS.REPLACE_MOVIES: | ||
return { | ||
...state, | ||
movies: action.newMovies | ||
}; | ||
case ACTIONS.CHANGE_SELECTED: | ||
return { | ||
...state, | ||
selected: action.newSelected | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { createStore } from "redux"; | ||
|
||
import reducer from "../reducer"; | ||
|
||
const store = createStore(reducer); | ||
|
||
export default store; |