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

Update todomvc example #1480

Closed
wants to merge 3 commits into from
Closed

Conversation

mwilc0x
Copy link
Contributor

@mwilc0x mwilc0x commented Mar 5, 2016

Hi @gaearon,

This is my attempt at #1354.

I basically took the todos example and built off of that, adding in some of the existing todomvc example code.

Things I did:

  • Store visibilityFilter in the state
  • Split into presentational and container components
  • Update the reducer code to use composition
  • Add Reselect
  • Update action/reducer tests
  • Add integrations for components using enzyme Use enzyme in tests #1481

The only thing I'm not sure about is testing components. Is there any way you would suggest for this?

I'd love to hear your feedback! I'm happy to make any changes required.

fixes #1354

Cheers


const VisibleTodoList = connect(
mapStateToProps,
mapDispatchToProps
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just pass action creators as object here for brevity. It would be equivalent to mapDispatchToProps in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, I'll make this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dan, just to clarify, would the way to do this be using bindActionCreators?

Copy link
Contributor

Choose a reason for hiding this comment

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

You can pass an object as second argument instead of mapDispatchToProps. It’s a documented shortcut and has the same effect 😉

@gaearon
Copy link
Contributor

gaearon commented Mar 6, 2016

This looks really great. For testing components I would suggest we start using Enzyme (but if you decide to add it please make sure to leave a note in #1481).

@mwilc0x
Copy link
Contributor Author

mwilc0x commented Mar 6, 2016

thanks Dan. I just left a comment there to say I would like to try adding it here only. I've never used it, but it looks great. Will start working on this tonight.

@gaearon
Copy link
Contributor

gaearon commented Mar 6, 2016

Actually there’s no rush: I’d rather see enzyme as a separate PR, and merge this sooner even if this means we drop component tests temporarily. Anything left to do here to bring it to mergeable state? I see travis is failing.

@mwilc0x
Copy link
Contributor Author

mwilc0x commented Mar 6, 2016

Ok, sounds good. The linter was failing on test files earlier.

Made the changes we discussed above, using bindActionCreators for brevity passing down multiple action creators.

I've tested it out locally and it looks good. As long as travis passes I would say this is ready to merge!

@@ -1,7 +1,7 @@
{
"name": "redux-todomvc-example",
"version": "0.0.0",
"description": "Redux TodoMVC example",
"description": "Redux Todos example",
Copy link
Contributor

Choose a reason for hiding this comment

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

TodoMVC

@mwilc0x
Copy link
Contributor Author

mwilc0x commented Mar 6, 2016

Thanks, fixed those above items.

One thing I did notice, when I inspect in chrome devtools I am seeing a lot of noise that looks like from sourcemaps? Any idea how to disable those messages?

image

@mwilc0x
Copy link
Contributor Author

mwilc0x commented Mar 6, 2016

So it looks like changing webpack devtool from cheap-module-eval-source-map to just eval makes those go away.

@gaearon
Copy link
Contributor

gaearon commented Mar 6, 2016

Try #cheap-module-eval-source-map?

@mwilc0x
Copy link
Contributor Author

mwilc0x commented Mar 6, 2016

good call! fixed

@mwilc0x
Copy link
Contributor Author

mwilc0x commented Mar 6, 2016

should we update dependencies as well?

redux, react-redux, webpack-dev-middleware, webpack-hot-middleware, babel-preset-react-hmre, expect

@mwilc0x
Copy link
Contributor Author

mwilc0x commented Mar 6, 2016

Ping, ready to merge.

@mwilc0x
Copy link
Contributor Author

mwilc0x commented Mar 7, 2016

I have enzyme tests for the components. Should I include them in this PR?

@timdorr
Copy link
Member

timdorr commented Mar 8, 2016

Can you squash some of these commits into more manageable chunks?

add initial state

don't hardcode todo id

add key to Link items

rename component to Header

move Footer into component

rename Footer container

handle show/hide of clear completed button

use bindActionCreators for brevity

enable hot reloading of reducers

add constants

fix warnings

import order

use uppercase for consistency
fix lint

fix lint
fix package name

move todomvc-app-css to dep

add missing dep

fix description and move dep

add enzyme tests
@mwilc0x
Copy link
Contributor Author

mwilc0x commented Mar 9, 2016

Rebased and squashed. Can you please review and let me know if this is ok?

@timdorr
Copy link
Member

timdorr commented Sep 4, 2016

Dan redid all the examples on create-react-app, so this probably needs a major update. I'm going to close for now but you can resubmit if you have the time to refactor everything. Sorry for the hassle!

@timdorr timdorr closed this Sep 4, 2016
@mwilc0x
Copy link
Contributor Author

mwilc0x commented Sep 5, 2016

Cool, no worries :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update TodoMVC example to be more in line with other examples
4 participants