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

event isn't exposed in handler #1

Open
jschr opened this issue Jun 8, 2015 · 2 comments
Open

event isn't exposed in handler #1

jschr opened this issue Jun 8, 2015 · 2 comments

Comments

@jschr
Copy link

jschr commented Jun 8, 2015

Hey great little library! I've been implementing some of these ideas into my own project with some slight changes. One of my favourite things so far is being able to deconstruct props/state with default values instead of needing to use getDefaultProps:

export default component(({ props: { count: 0 } }) => {
  return <div>{count}</div>;
});

However I did notice that in your handler wrapper that the original event isn't passed through:

https://github.com/aickin/functional-react/blob/master/index.js#L26

I ended up changing the handler wrapper to pass in e as the 2nd argument but I thought it would be worth mentioning.

@aickin
Copy link
Owner

aickin commented Jun 9, 2015

I like the idea of destructuring default values into the props; really clever!

You're right that the original event needs to be passed through. I'll do that in the next version.

@jschr
Copy link
Author

jschr commented Jun 9, 2015

Thanks! I must say that using this functional wrapper has been a breath of fresh air over relying on this. I'm curious to why you opted for only passing props/state as an object rather every dependency as a object that can be deconstructed in every function?

const render = ({ props, handler }) => { ... }
const shouldComponentUpdate = ({ props, nextProps }) => { ... }
const componentWillMount = ({ state, setState }) => { ... }

as opposed to

const render = ({ props }, handler }) => { ... }
const shouldComponentUpdate = ({ props }, { props: nextProps }) => { ... }
const componentWillMount = ({ state }, setState) => { ... }

Is the former a bad idea? Right now I'm torn between the two methods.

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

No branches or pull requests

2 participants