-
Notifications
You must be signed in to change notification settings - Fork 20
home task 7 #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
home task 7 #67
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,10 @@ class Article extends Component { | |
| error: null | ||
| } | ||
|
|
||
| static contextTypes = { | ||
| dictionary: PropTypes.object | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. тут и в других местах: лучше сделай декоратор либо компонент-обертку для локализации, чтоб не обращатся каждый раз к контексту, иначе потом тяжело будет что-либо поменять
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Спасибо |
||
| } | ||
|
|
||
| componentDidCatch(error) { | ||
| console.log('---', error) | ||
| this.setState({ error }) | ||
|
|
@@ -25,6 +29,7 @@ class Article extends Component { | |
|
|
||
| render() { | ||
| console.log('---', 'rendering Article') | ||
| const {dictionary: {deleteMe, open, close}} = this.context | ||
| if (this.state.error) return <h2>{this.state.error.message}</h2> | ||
|
|
||
| const { isOpen, article, onButtonClick } = this.props | ||
|
|
@@ -38,10 +43,10 @@ class Article extends Component { | |
| className = "test__article--button" | ||
| onClick={() => onButtonClick(article.id)} | ||
| > | ||
| {isOpen ? 'close' : 'open'} | ||
| {isOpen ? close : open} | ||
| </button> | ||
| <button onClick = {this.handleDelete}> | ||
| delete me | ||
| {deleteMe} | ||
| </button> | ||
| </h2> | ||
| <CSSTransition | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| const dictionary = { | ||
| username: 'Имя пользователя', | ||
| articlesPage: 'Статьи', | ||
| pleaseSelectArticle: 'Выберите статью', | ||
| loading: 'Загрузка', | ||
| hideComments: 'Спрятать коментарии', | ||
| showComments: 'Показать комментарии', | ||
| articlePage: 'Стараница статей', | ||
| deleteMe: 'Удалить', | ||
| open: 'Открыть', | ||
| close: 'Закрыть' | ||
| } | ||
|
|
||
| export default dictionary |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,11 @@ | ||
| import articles from "../reducer/articles"; | ||
| import comments from "../reducer/comments"; | ||
|
|
||
| export default store => next => action => { | ||
| console.log('---', 'state before: ', store.getState()) | ||
| console.log('---', 'dispatching action: ', action) | ||
|
|
||
| next(action) | ||
|
|
||
| console.log('---', 'state after: ', store.getState()) | ||
| console.log('---', 'state after: ', store.getState().articles.toJS(), store.getState().comments.toJS()); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ import { | |
| START, SUCCESS, FAIL | ||
| } from '../constants' | ||
| import { arrToMap } from './utils' | ||
| import { Record } from 'immutable' | ||
| import { Record, fromJS } from 'immutable' | ||
|
|
||
| const ArticleRecord = Record({ | ||
| id: null, | ||
|
|
@@ -41,7 +41,7 @@ export default (articles = new ReducerState(), action) => { | |
|
|
||
| case LOAD_ALL_ARTICLES + SUCCESS: | ||
| return articles | ||
| .set('entities', arrToMap(response, ArticleRecord)) | ||
| .update('entities', entities => entities.merge(arrToMap(response, ArticleRecord), entities)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ты делаешь 2 мерджа |
||
| .set('loading', false) | ||
| .set('loaded', true) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше для этого Provider завести