0
 {announcements.map( ( v, i ) =>
    {
    const type = v.taxonomy && v.taxonomy.toUpperCase();
    if ( props.filter && props.filter.announcement.toUpperCase() != type )
      {
          return i < 1 
                 && <p key={i} className="text-xs">No announcements</p>;
       }
    }
}

Say props.filter.announcement == "TRADE" and type has "TRADE, INVEST, EFT,....." I want to check if the filter props exist and filter.announcement does not have any type then return no annoucement para. But right now say I'm filtering "TRADE" category, when the filter matches the type, it gives a different return. Whereas it also returns this not matching function as during the map loop the posts having category other than TRADE match the condition so I'm getting both TRADE match return as well as no announcement return. How can I make this condition work?

Image link here here

mplungjan
  • 169,008
  • 28
  • 173
  • 236
RawDev
  • 19
  • 2
  • Please post a [mcve] of your attempt, noting input and expected output using the [`[<>]`](https://meta.stackoverflow.com/questions/358992/ive-been-told-to-create-a-runnable-example-with-stack-snippets-how-do-i-do) snippet editor. – mplungjan Sep 15 '21 at 07:24
  • `i` will never be less than 1, surely. – Andy Sep 15 '21 at 07:24
  • ```props.filter.announcement``` has only one of the multiple entries within type ```TRADE, INVEST, EFT,.... ```? Then its just a basic syntax error may be? Try doing ```type.split(',').indexOf(props.filter.announcement.toUpperCase()) > -1``` to check. But need more information before confirming this. – Himadhar H Sep 15 '21 at 07:36

0 Answers0