[HELP] [React] Object keys are not valid? | Sololearn: Learn to code for FREE!


[HELP] [React] Object keys are not valid?

I'm making a simple searcher, and I need to iterate through an emulation of db, then check if db has ones in input. I don't understand about which keys React is talking about, so pls help me. https://code.sololearn.com/WMkhJHhTFKcy/?ref=app

10/16/2018 8:52:43 PM


3 Answers

New Answer


ŧåŀēņţłĕşš_ģųŷ oh sorry It's just that the first error i encountered in the code is missing Object.values() method. I see the problem now. When you find a match, for example, by inputting "Alice", you push the entire object to the results array and on the render method you attempt to render it. That's not how React works. React cannot render plain javascript objects like this. In your case you should create some other component to represent a single result which will display the "name", "profession" and "age" of a single result object. The render in the Search component should render a list of such "Result" components


Burey sorry but it isn't an explanation of the problem


Try adding polyfills https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Object/values