react-input-mask icon indicating copy to clipboard operation
react-input-mask copied to clipboard

[@next] findDOMNode is deprecated in StrictMode

Open cutterbl opened this issue 5 years ago • 29 comments

So I was playing around with the @next build of react-input-mask, and specifically the bit about being able to wrap custom components. I was making some progress, but notice the following error hitting the console

findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of InputMaskChildrenWrapper which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://fb.me/react-strict-mode-find-node

You can see this in the CodeSandbox I created for testing. I provided some very basic commenting in the InputWrapper and Input components about basic usage.

Also, attempting to change my input value (in the input) threw an Error about string.split not being a function?

cutterbl avatar Oct 09 '20 22:10 cutterbl

Same, I traced deprecation warnings to this package, but I gather from #184 that this project is dead.

scott-r-lindsey avatar Oct 19 '20 17:10 scott-r-lindsey

Same issue 😞

SherAtrium avatar Feb 18 '21 07:02 SherAtrium

I would appreciate if this issue was fixed.

paulocf92 avatar Mar 06 '21 15:03 paulocf92

The same problem!!

AndreyPatseiko avatar Mar 26 '21 06:03 AndreyPatseiko

Same

anton-prok avatar Apr 05 '21 06:04 anton-prok

I have the same issue

Temirtator avatar Apr 06 '21 10:04 Temirtator

Please stop the "same" posts. You can upvote the original post or even better create a pull request. Everyone including the maintainer are aware of the warning.

donaldpipowitch avatar Apr 06 '21 17:04 donaldpipowitch

I have send PR. Can somebody check it @sanniassin?

https://github.com/sanniassin/react-input-mask/pull/255

Temirtator avatar Apr 08 '21 12:04 Temirtator

same issue

ben4956 avatar Sep 03 '21 04:09 ben4956

we depend a lot on this package, and due to the delay and lack of feedback, we decided to fork.

https://github.com/comigotech/react-input-mask

We have already managed to publish the package and are already using it directly.

I kept the credits and we linked to this same package

gilvaju avatar Jan 04 '22 17:01 gilvaju

we depend a lot on this package, and due to the delay and lack of feedback, we decided to fork.

https://github.com/comigotech/react-input-mask

We have already managed to publish the package and are already using it directly.

I kept the credits and we linked to this same package

hm, why do I have the same issue with "^3.0.0-alpha.2"? React v- "17.0.2"

Rigii avatar May 24 '22 09:05 Rigii

The haven't published the package, or at least not with the react-input-mask name, so install from github

BorjaRafolsMartinez avatar May 25 '22 17:05 BorjaRafolsMartinez

we depend a lot on this package, and due to the delay and lack of feedback, we decided to fork. https://github.com/comigotech/react-input-mask We have already managed to publish the package and are already using it directly. I kept the credits and we linked to this same package

hm, why do I have the same issue with "^3.0.0-alpha.2"? React v- "17.0.2"

Hi, the package is comigo-tech-react-input-mask

gilvaju avatar May 26 '22 00:05 gilvaju

lmao 2022 and still facing same warning

excal1bu7 avatar Jul 10 '22 14:07 excal1bu7

Any news on this issue?

matheusrgarcia avatar Jul 13 '22 19:07 matheusrgarcia

I'll be working on this issue on the weekend.

Personal reminder: github.dev/sanniassin/react-input-mask/blob/master/src/index.js

matheusrgarcia avatar Jul 13 '22 19:07 matheusrgarcia

Any solution? @gilvaju your package have the types package to install?

tutods avatar Oct 11 '22 20:10 tutods

still up :(

alexnatea avatar Feb 10 '23 13:02 alexnatea

This is effectively a duplicate of https://github.com/sanniassin/react-input-mask/issues/198

ianchanning avatar Feb 25 '23 04:02 ianchanning

i would just use this library instead: https://github.com/text-mask/text-mask/tree/master/react/#readme

nathanbeers avatar Mar 19 '23 15:03 nathanbeers

This did fix in this PR https://github.com/zenbill/react-input-mask/pull/1, but since wouldn't be published on npm. I'm using react-number-format in the npm trends many developers also using it.

mariosantosdev avatar May 09 '23 18:05 mariosantosdev

We have released our version with a fix for this on NPM https://github.com/mona-health/react-input-mask/ .

ianchanning avatar May 19 '23 13:05 ianchanning

We have released our version with a fix for this on NPM https://github.com/mona-health/react-input-mask/ .

Doesn't work with typescript

404 Not Found - GET https://registry.npmjs.org/@types%2fmona-health__react-input-mask - Not found

bloodsuckers-spb avatar Jul 31 '23 14:07 bloodsuckers-spb

@bloodsuckers-spb Yeah I might get round to converting it to typescript.

Also it does work with typescript but it gives you little squiggles :shrug:

ianchanning avatar Sep 03 '23 12:09 ianchanning

For anyone encountering issues with typescript, here is a solution.

  1. Create a comigo-tech-react-input-mask.d.ts ormona-health/react-input-mask.d.ts file
  2. Paste the following code:
declare module 'comigo-tech-react-input-mask' {
  import * as React from 'react';

  export interface Selection {
    start: number;
    end: number;
  }

  export interface InputState {
    value: string;
    selection: Selection | null;
  }

  export interface BeforeMaskedStateChangeStates {
    previousState: InputState;
    currentState: InputState;
    nextState: InputState;
  }

  export interface Props extends React.InputHTMLAttributes<HTMLInputElement> {
    /**
     * Mask string. Format characters are:
     * * `9`: `0-9`
     * * `a`: `A-Z, a-z`
     * * `\*`: `A-Z, a-z, 0-9`
     *
     * Any character can be escaped with backslash, which usually will appear as double backslash in JS strings.
     * For example, German phone mask with unremoveable prefix +49 will look like `mask="+4\\9 99 999 99"` or `mask={"+4\\\\9 99 999 99"}`
     */
    mask: string | Array<string | RegExp>;
    /**
     * Character to cover unfilled editable parts of mask. Default character is "_". If set to null, unfilled parts will be empty, like in ordinary input.
     */
    maskChar?: string | null | undefined;
    maskPlaceholder?: string | null | undefined;
    /**
     * Show mask even in empty input without focus.
     */
    alwaysShowMask?: boolean | undefined;

    ref?: React.Ref<HTMLInputElement> | undefined;
    /**
     * In case you need to implement more complex masking behavior, you can provide
     * beforeMaskedStateChange function to change masked value and cursor position
     * before it will be applied to the input.
     *
     * * previousState: Input state before change. Only defined on change event.
     * * currentState: Current raw input state. Not defined during component render.
     * * nextState: Input state with applied mask. Contains value and selection fields.
     */
    beforeMaskedStateChange?(states: BeforeMaskedStateChangeStates): InputState;
  }

  export class InputMask extends React.Component<Props> {}

  export default InputMask;
}

BorjanKalinoski avatar Mar 01 '24 14:03 BorjanKalinoski

I gave this a shot on another project.

https://github.com/BorjaRafolsMartinez/react-masked-input

I don't think it is 100% compatible with this project but I believe most of it has been migrated and requires little change in your project. It has full TS support.

The main reason was the lack of response on this project.

BorjaRafolsMartinez avatar Mar 01 '24 15:03 BorjaRafolsMartinez

Así que estaba jugando con la @nextcompilación de react-input-mask, y específicamente con la posibilidad de envolver componentes personalizados. Estaba progresando un poco, pero noté el siguiente error al acceder a la consola

findDOMNode está en desuso en StrictMode. A findDOMNode se le pasó una instancia de InputMaskChildrenWrapper que está dentro de StrictMode. En su lugar, agregue una referencia directamente al elemento al que desea hacer referencia. Obtenga más información sobre el uso de referencias de forma segura aquí: https://fb.me/react-strict-mode-find-node

Puedes ver esto en CodeSandbox que creé para probar. Proporcioné algunos comentarios muy básicos en los componentes InputWrappery Inputsobre el uso básico.

Además, al intentar cambiar mi valor de entrada (en la entrada), se produjo un error que indica que string.splitno es una función.

I found the solution in https://www.npmjs.com/package/@react-input/mask

ValeSack avatar Jun 24 '24 18:06 ValeSack