Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// make a "base" component
const FakeButton = (props) => (
cursor: 'default',
border: '1px solid',
borderRadius: '3px',
onKeyDown={(e) => e.key === 'Enter' && props.onClick(e)}
onKeyUp={(e) => e.key === 'Space' && props.onClick(e)}
FakeButton.defaultProps = {
onClick() {}
// wrap it to add specific behavior
const AlertButton = (props) => (
onClick={(event) => alert(props.message)}
// use it anywhere
render(<AlertButton message="hello"/>, el);

This comment has been minimized.

Copy link

@vidoss vidoss commented Sep 25, 2015

Looks great. Is there some kind of transformation I am missing ? How is React.createElement() taking the return of another createElement() as first argument ? Adding this to jsfiddle does throw this error as expected.

Uncaught TypeError: Can't add property context, object is not extensible

what am i missing ?


This comment has been minimized.

Copy link

@vidoss vidoss commented Oct 7, 2015

oh! version 0.14 thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.