Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!