Last active
September 9, 2015 17:10
-
-
Save ryanflorence/5e6a1e3d02ba993c1415 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Thing = (props) => ( | |
<div>look {props.name}! no state!</div> | |
) | |
render(<Thing name="Ma"/>, el) |
Should we handle props in events likewise?
function handleClick(name, e) {
console.log(`The name is "${name}".`);
}
function Thing ({name}) {
return (
<div onClick={handleClick.bind(null, name)}>look {name}! no state!</div>
)
}
@Yomguithereal It might look nicer to push handleClick
within Thing
scope.
Maybe you guys like https://github.com/stoeffel/react-mini. It has a similar approach.
@bebraw it would indeed be cleaner.
Just to let you know. The new react-mini api is almost the same as you suggested here.
https://github.com/stoeffel/react-mini#api
import pure from 'react-mini/pure';
const Thing = pure(({name}) => {
function handleClick(e) {
console.log(`The name is "${name}".`);
}
return (
<div onClick={handleClick}>look {name}! no state!</div>
)
});
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe