02_lesson: Add canSave check function to disable Save Post button
This commit is contained in:
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…
x
Reference in New Issue
Block a user