Skip to content

Instantly share code, notes, and snippets.

@ernestofreyreg
Last active July 19, 2017 06:44
Show Gist options
  • Save ernestofreyreg/a77e00fc4eef7f090d139f9a37dba6c0 to your computer and use it in GitHub Desktop.
Save ernestofreyreg/a77e00fc4eef7f090d139f9a37dba6c0 to your computer and use it in GitHub Desktop.
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