);
}
}
-function mapStateToProps({ posts }, ownProps) {
+function mapStateToProps({ posts }, ownProps) { // ownProps retrieve the componet props, so in this case we have access to React-Router id props from here
return { post: posts[ownProps.match.params.id] };
}
+/*function mapStateToProps(state) {
+ return { post : state.posts. };
+} din't work coz the state return an obj that as a id as key and the request obj as a param, [he setted like that]*/
export default connect(mapStateToProps, { fetchPost, deletePost })(PostsShow);
diff --git a/blog/src/reducers/reducer_posts.js b/blog/src/reducers/reducer_posts.js
index 415e1c96..92250832 100644
--- a/blog/src/reducers/reducer_posts.js
+++ b/blog/src/reducers/reducer_posts.js
@@ -6,6 +6,11 @@ export default function(state = {}, action) {
case DELETE_POST:
return _.omit(state, action.payload);
case FETCH_POST:
+ /*const post = action.payload.data;
+ const postid = action.payload.data.id
+ const newstate = { ...state }; // this spread operator does't seem to have a real utility on my opinion
+ newstate[postid] = post;// add a new property for the obj newstate with the id as a key and post as a value
+ return newstate;*/
return { ...state, [action.payload.data.id]: action.payload.data };
case FETCH_POSTS:
return _.mapKeys(action.payload.data, "id");
diff --git a/blog/style/style.css b/blog/style/style.css
index ab51de76..963b86e5 100644
--- a/blog/style/style.css
+++ b/blog/style/style.css
@@ -1,3 +1,10 @@
form a {
margin-left: 5px;
}
+
+/*content post take formatting*/
+p.pre-content { white-space: pre-wrap;
+ white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
+ white-space: -pre-wrap; /* Opera 4-6 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ word-wrap: break-word; /* Internet Explorer 5.5+ */;}
diff --git a/book_list/src/components/app.js b/book_list/src/components/app.js
index c1eb0f04..4b011195 100644
--- a/book_list/src/components/app.js
+++ b/book_list/src/components/app.js
@@ -1,10 +1,10 @@
import React from "react";
-import { Component } from "react";
+//import { Component } from "react";
import BookList from "../containers/book-list";
import BookDetail from "../containers/book-detail";
-export default class App extends Component {
+/*export default class App extends Component {
render() {
return (
);
}
-}
+}*/
+
+// functional version component (why it uses class component since there's no state involved in the App component?)
+ const App = () => {
+ return (
+
+
+
+
+ );
+ }
+
+export default App;
\ No newline at end of file
diff --git a/book_list/src/containers/book-list.js b/book_list/src/containers/book-list.js
index 9c1335b5..83069877 100644
--- a/book_list/src/containers/book-list.js
+++ b/book_list/src/containers/book-list.js
@@ -10,7 +10,7 @@ class BookList extends Component {
diff --git a/video_browser/src/index.js b/video_browser/src/index.js
index c3908c86..c2f9aeeb 100644
--- a/video_browser/src/index.js
+++ b/video_browser/src/index.js
@@ -6,17 +6,22 @@ import SearchBar from "./components/search_bar";
import VideoList from "./components/video_list";
import VideoDetail from "./components/video_detail";
const API_KEY = "AIzaSyAuQCVeNfKhtRk9KlChQPT1nO27DPO_5Ss";
+const iterm = "surfboards";
class App extends Component {
constructor(props) {
super(props);
+
+
this.state = {
videos: [],
- selectedVideo: null
+ selectedVideo: null
};
+
+ //this.iterm = "surfboards";
- this.videoSearch("surfboards");
+ this.videoSearch(iterm);
}
videoSearch(term) {
@@ -27,15 +32,28 @@ class App extends Component {
});
});
}
+
+ /* setTimeout attempt (work differtly coz waits but then execute the function for every typing)
+ delayedVideoSearch = term => setTimeout(() => this.videoSearch(term), 5000);*/
+ //my debouced version [debounce (Lodash library method) does the trick, waits and then executes the function just once]
+ debouncedVideoSearch = _.debounce(term => {
+ this.videoSearch(term);
+ }, 500);
render() {
+ /* Original version [not clear having the same name and I don't know why to put it in the render function (maybe just to take the same name)]
const videoSearch = _.debounce(term => {
this.videoSearch(term);
- }, 300);
+ }, 500);*/
+
+
return (