02_lesson: Add canSave check function to disable Save Post button
parent
00fcac1145
commit
75f98755b7
|
@ -25,6 +25,8 @@ const AddPostForm = () => {
|
|||
}
|
||||
};
|
||||
|
||||
const canSave = Boolean(title) && Boolean(content) && Boolean(userId);
|
||||
|
||||
const usersOptions = users.map((user) => (
|
||||
<option key={user.id} value={user.id}>
|
||||
{user.name}
|
||||
|
@ -55,7 +57,7 @@ const AddPostForm = () => {
|
|||
value={content}
|
||||
onChange={onContentChanged}
|
||||
/>
|
||||
<button type="button" onClick={onSavePostClicked}>
|
||||
<button type="button" onClick={onSavePostClicked} disabled={!canSave}>
|
||||
Save Post
|
||||
</button>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue