Skip to content
Advertisement

REACT: SELECT from MYSQL

i a new user and a new in React world. I need help to solve this situation about a Select with values from mysql DB. I receive the values, but the select goes in infinite loop.

The error is surely in this file cause server.js works without problem!! Really thanks for the help, and sorry if it could be a stupid question. I m studying react from one week and i have not found answers on internet

Advertisement

Answer

Wrap the selectOptions(); call in an useEffect (since loading data and mutating state based on it is a side effect).

The empty dependency array (documented above) means the effect is only executed once on mount.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement