Objects are not valid as a React child in React Native

409 views Asked by At

By rendering the FlatList I always get the error "Objects are not valid as a React child (found: object with keys {dispatchConfig, _targetInst, _dispatchListeners, _dispatchInstances, nativeEvent, type, target, currentTarget, eventPhase, bubbles, cancelable, timeStamp, defaultPrevented, isTrusted, isDefaultPrevented, isPropagationStopped}). If you meant to render a collection of children, use an array instead.".

I find out that the rendered item in the Text component needs to be a primitive type but I think it's rendering a string which is a primitive type.

My Code

1

There are 1 answers

0
Kai On BEST ANSWER

The problem is that you are passing objects rather than strings into the courseGoals array. This is because the onChange handler of TextInput takes a whole event object.

Switch it to onChangeText, which passes a string, and it should work.