bl00mber / react-phone-input-2

:telephone_receiver: Highly customizable phone input component with auto formatting

Home Page:https://bl00mber.github.io/react-phone-input-2.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

e3.replace is not a function and make app crash

frederic117 opened this issue · comments

commented

I got an error that make my app crash
I hope you can help me :)

Uncaught TypeError: e3.replace is not a function
at t2.value (lib.js:6:51131)
at t2.value (lib.js:6:50775)

the above error occurred in the component:
at t2 (http://localhost:5173/node_modules/.vite/deps/react-phone-input-2.js?v=3e5bcc3a:1079:11)

return function(e3, t3) {
if ("function" != typeof t3 && null !== t3)
throw new TypeError("Super expression must either be null or a function");
e3.prototype = Object.create(t3 && t3.prototype, { constructor: { value: e3, writable: true, configurable: true } }), t3 && h(e3, t3);
}(t2, e2), r2 = t2, (l2 = [{ key: "componentDidMount", value: function() {
document.addEventListener && this.props.enableClickOutside && document.addEventListener("mousedown", this.handleClickOutside), this.props.onMount && this.props.onMount(this.state.formattedNumber.replace(/[^0-9]+/g, ""), this.getCountryData(), this.state.formattedNumber);
} }, { key: "componentWillUnmount", value: function() {
document.removeEventListener && this.props.enableClickOutside && document.removeEventListener("mousedown", this.handleClickOutside);
} }, { key: "componentDidUpdate", value: function(e3, t3, r3) {
e3.country !== this.props.country ? this.updateCountry(this.props.country) : e3.value !== this.props.value && this.updateFormattedNumber(this.props.value);
} }, { key: "updateFormattedNumber", value: function(e3) {
if (null === e3)
return this.setState({ selectedCountry: 0, formattedNumber: "" });
var t3 = this.state, r3 = t3.onlyCountries, n2 = t3.selectedCountry, a2 = t3.hiddenAreaCodes, o2 = this.props, i2 = o2.country, u2 = o2.prefix;
if ("" === e3)
return this.setState({ selectedCountry: n2, formattedNumber: "" });
var c2, s2, l3 = e3.replace(/\D/g, "");

Same Problem Here, anyone who can hel?

@frederic117 @marlonfrade I too just faced this issue. Make sure when you're setting the state, that you're not setting an object of Phone. This should resolve it.

@frederic117 @marlonfrade I too just faced this issue. Make sure when you're setting the state, that you're not setting an object of Phone. This should resolve it.

Thanks for the helpful tip on how to fix that state issue! Setting the state to a plain object instead of a Phone object did the trick. I really appreciate you taking the time to provide a solution