-1

In the code snippet given, I have a problem that the if (descriptionValue) condition does not wait for setDescriptionValue(content). How to fix this problem? (Condition if (props.isOfferFilter) met)

  const onClickHandler: () => Promise<void> = async () => {
if (props.isOfferFilter) {
  content = getInnerHtml(id);
  setDescriptionValue(content);
}
if (nameValue && descriptionValue && catValue && projectIdValue) {
Miangel
  • 1
  • 1
  • `if (nameValue && content && catValue && projectIdValue`? – Janar May 28 '22 at 10:46
  • Calling `setDescriptionValue` does not change the value stored in the local variable `descriptionValue`, it just asks react to rerender the component. Since you know the new state is `content`, i recommend you check that value instead. – Nicholas Tower May 28 '22 at 10:46
  • I need to pass the content variable only if the first condition is met, otherwise another value is passed – Miangel May 28 '22 at 11:35

0 Answers0