Skip to content
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

Week4 #40

Closed
wants to merge 16 commits into from
Closed

Week4 #40

wants to merge 16 commits into from

Conversation

ekocibar
Copy link

Sorry for late. I had very busy week.

Copy link
Contributor

@joostlubach joostlubach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the main thing is that you're not using <Provider> and @inject. Otherwise good!

import './index.css';


@observer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to make the TodoItem component a MobX-observer? TodoItem is not getting its data directly from the store, only from its props, so you don't need to do this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I need that, 'deleteTodo' and 'changeStatus' do not functioning otherwise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import {observer} from 'mobx-react';
import {todoStore} from './stores';

@observer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget: in the recent version of mobx-react you need to also add @inject.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added :)

};

onDelete = (todoID) => {
todoStore.onDelete(todoID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing: todoStore.onDelete is not an event handler, but a method on todoStore. Best to just call it delete or deleteTodo.

}

onDone = (todoID) => {
todoStore.onDone(todoID);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

</div>
<ul>
{todoStore.todos.map((todoItem, i) => (
<React.Fragment key={todoItem.id}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use a Fragment here, as there's only one child. You can just render the <TodoItem> directly.

}

@action
onDelete(todoID){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment on naming above.

}

@action
onDone(todoID){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment on naming above.

this.todos.push(todo);
}

@action
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! This is an action method, and you're correct to mark it as such.

@ekocibar
Copy link
Author

I have changed some after your comments.
Thank you for your time @joostlubach.

@isaachinman isaachinman closed this Mar 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants