Nisha Patel
Query: React: Why Ternary operator logic not working for boolean evaluating to false when it's not false
Solution
Make sure to recheck your if statement. That might be creating the problem. Or, you are not passing the props correctly which is why it is showing the false result.
You could spread the complete object to pass all the props:
Demo:
However, since you'll have to loop through the items in the projects array, this is not very scalable. To see if that is the last item in the list, use the loop's iterator (map() in the examples):
Demo:
Suggested blogs:
>How to conditionally render different arrays in React?
>Fix react useState and array.map not work issue
>Making infinite scrolling using react-query
>How does React State with JSON arrays affect performance?
>setlist{nosep} not work in the acronym package
>Fix ScrollIntoView not working issue
>Testing react component with jest
>How you can Show or hide elements in React?
>Testing react components using Hooks and Mocks
>Tips for using React Redux Hooks to show or hide React components