Last active
February 9, 2019 13:45
-
-
Save hckhanh/c896abb29882e986f7f417bfb091cd58 to your computer and use it in GitHub Desktop.
editMode will be declared inline
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 PropTypes from 'prop-types'; | |
import React, { Fragment, useState } from 'react'; | |
import EditModeItem from './EditModeItem'; | |
import './style.scss'; | |
import ViewModeItem from './ViewModeItem'; | |
export default function EditableItem({ data }) { | |
const [editMode, setEditMode] = useState(false); | |
return ( | |
<Fragment> | |
{editMode ? ( | |
<EditModeItem data={data} onCancel={() => setEditMode(false)} /> | |
) : ( | |
<ViewModeItem data={data} onEdit={() => setEditMode(true)} /> | |
)} | |
<div className="editable-Item-divider" /> | |
</Fragment> | |
); | |
} | |
EditableItem.propTypes = { | |
data: PropTypes.object.isRequired | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment