Last active
July 19, 2017 06:44
-
-
Save ernestofreyreg/a77e00fc4eef7f090d139f9a37dba6c0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React from 'react' | |
import PropTypes from 'prop-types' | |
import withEditableCellLogic from './with-editable-cell-logic' | |
const EditableCellView = ({ | |
value, | |
modifyValue, | |
editing, | |
changedValue, | |
changeValue, | |
startEditing, | |
stopEditing, | |
checkEndChanging | |
}) => ( | |
<div className='EditableCell'> | |
{editing | |
? ( | |
<input | |
type='text' | |
value={changedValue} | |
onChange={changeValue} | |
onKeyPress={checkEndChanging(modifyValue)} | |
autoFocus | |
/> | |
) | |
: <div className='value' onClick={startEditing(value)}>{value}</div> | |
} | |
</div> | |
) | |
EditableCellView.propTypes = { | |
value: PropTypes.string.isRequired, | |
modifyValue: PropTypes.func.isRequired, | |
} | |
export default withEditableCellLogic(EditableCellView) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment