Search code examples
reactjschakra-ui

How can I not pass children as props. Instead, nest children between the opening and closing tags on React?


error says : Do not pass children as props. Instead, nest children between the opening and closing tags when i add this part "children={}"

i'm not familiar with react and chakra so can somebody help solving this prolem ?

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>

<Stack id='phone'>
  <InputGroup>
    <InputLeftElement pointerEvents='none' children={<PhoneIcon color='gray.300' />} />
    <Input
      type='tel'
      name={`${type}[phone]`}
      autoComplete='phone'
      value={Phone}
      placeholder='Numero de telephone'
      className='chakra-input'
    />
  </InputGroup>
</Stack>


Solution

  • I believe you need to change this:

    <InputLeftElement pointerEvents='none' children={<PhoneIcon color='gray.300' />} />
    

    To this

    <InputLeftElement pointerEvents='none'>
      <PhoneIcon color='gray.300' />
    </InputLeftElement>