score:1

Accepted answer

it seems that you are spreading a string instead of an array (household). this results in the string being separated into the individual characters.

making sure household is an array should do the trick.

to ensure this you could require the npm library "prop-types" which ensures that props have a specific format when passed into a component.

used like:

[componentname].proptypes = {
household: proptypes.arrayof(proptypes.string).isrequired
//... other props
}

if in the end not an array of strings but a string is passed you would get a console error, making it easier to understand what goes wrong


Related Query

More Query from same tag