Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why is react giving me an error that it expected a function call and instead got an expression?

Ive seen a lot of this question here but none of the answers provided seems to be answering my scenario.

I have this code that looks so simple

   const getSpecificMedicineWithId = (number) => {
    const filteredData = mockListOfMedicines.find((medicine) => {
      medicine.medicineId === number;
    });

    return filteredData;
  };

I get this error

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

 Line 60:7:  Expected an assignment or function call and instead saw an expression  no-unused-expressions

What could go wrong with such a simple function? Please help.

>Solution :

you just need to return value from the find call back,hope this will help.

const getSpecificMedicineWithId = (number) => {
const filteredData = mockListOfMedicines.find((medicine) => {
  return medicine.medicineId === number;
});

return filteredData;
};
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading