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) => (
|
const usersOptions = users.map((user) => (
|
||||||
<option key={user.id} value={user.id}>
|
<option key={user.id} value={user.id}>
|
||||||
{user.name}
|
{user.name}
|
||||||
|
@ -55,7 +57,7 @@ const AddPostForm = () => {
|
||||||
value={content}
|
value={content}
|
||||||
onChange={onContentChanged}
|
onChange={onContentChanged}
|
||||||
/>
|
/>
|
||||||
<button type="button" onClick={onSavePostClicked}>
|
<button type="button" onClick={onSavePostClicked} disabled={!canSave}>
|
||||||
Save Post
|
Save Post
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue