Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

178
Visualizações
React expect string or class/function but got object, when using Check the render method of `ForwardRef(Input)`. React-hook

I am using react-phone-number-input and some custom inputs.

I would like to use my custom input within this library.

as you can see from the Documentation, I can use the following props :

inputComponent

to use a custom input, as long as

Phone number <input/> component.

Receives properties:

value: string — The formatted value.
onChange(event: Event) — Updates the formatted value from event.target.value.
onFocus() — Is used to toggle the --focus CSS class.
onBlur() — Is used to toggle the --focus CSS class.
Other properties like type="tel" or autoComplete="tel" that should be passed through to the DOM <input/>.
Must also either use React.forwardRef() to "forward" ref to the <input/> or implement .focus() method.

So I have done the following :

<PhoneInputWithCountry inputComponent={<Input />}/>

With my input beeing the following (It is simplified, but globally it looks like this) :



export const Input = forwardRef<HTMLInputElement, InputProps>(
  (
    {
      value,
      disabled,
      onBlur,
      prefixComponent,
      suffixComponent,
      ...rest
    },
    ref
  ) => {
    return (
      <div>
        <input
          disabled={disabled}
          onBlur={onBlur}
          ref={ref}
          value={value}
          {...rest}
        />
      </div>
    );
  }
);

I think all looks fine, but I get prompted with

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of ForwardRef(Input).

I do not understand at all what is wrong here.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda