question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

undefined is not an object (evaluating 'e.slice')

See original GitHub issue

After upgrading to 1.6.0 from 1.4.10 as a part of working around https://github.com/nosir/cleave.js/issues/593 , I have now seen this come up twice in bug reports:

TypeError undefined is not an object (evaluating 'e.slice') 
    ../node_modules/cleave.js/dist/cleave-react-node.js:2536 getPostDelimiter
    ../node_modules/cleave.js/dist/cleave-react-node.js:344 onChange
    [native code] onChange
    ../node_modules/react-dom/cjs/react-dom.production.min.js:15:202 ka
    ../node_modules/react-dom/cjs/react-dom.production.min.js:15:355 qa
    ../node_modules/react-dom/cjs/react-dom.production.min.js:16:31 ra
    ../node_modules/react-dom/cjs/react-dom.production.min.js:16:235 wa
    ../node_modules/react-dom/cjs/react-dom.production.min.js:17:239 Aa
    [native code] forEach
    ../node_modules/react-dom/cjs/react-dom.production.min.js:17:19 ya
    ../node_modules/react-dom/cjs/react-dom.production.min.js:17:411 Ba
    ../node_modules/react-dom/cjs/react-dom.production.min.js:85:402 Pd
    ../node_modules/react-dom/cjs/react-dom.production.min.js:87:246 Ud
    [native code] Be
    ../node_modules/scheduler/cjs/scheduler.production.min.js:20:126 
    ../node_modules/react-dom/cjs/react-dom.production.min.js:207:389 fj
    ../node_modules/react-dom/cjs/react-dom.production.min.js:86:239 Sd
    [native code] je

I haven’t figured out how to reproduce it yet, but the relevant code seems to have been changed recently at https://github.com/nosir/cleave.js/pull/582

So far the bug has happened on this device:

Safari 13.0.5
en-US
Mac OS X 10.15

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:10
  • Comments:11

github_iconTop GitHub Comments

2reactions
sudosubincommented, Aug 20, 2021

I encountered the same issue, but I did not want to downgrade the Cleave.js version. The issue is that lastInputValue is undefined untill the first input, so I just initialized it with empty string. (using onInit method)

import { ComponentProps } from 'react';
import Cleave from 'cleave.js/react';

const onInit: ComponentProps<typeof Cleave>['onInit'] = (owner) => {
  (owner as any).lastInputValue = '';
};

const WrappedCleave = (props: any) => {
  return (
    <Cleave
      onInit={onInit}
      {...props}
    />
  )
};

Now it works for me. Any comment would be welcome.

2reactions
rogorman9commented, Nov 3, 2020

Just to add another case for this, I’m getting what I think is a related bug when I try to use Enzyme’s simulate function to simulate a change event on the native input element within a Jest unit test. The error I’m getting in this case is:

TypeError: Cannot read property 'slice' of undefined

      at Object.getPostDelimiter (node_modules/cleave.js/dist/cleave-react-node.js:2536:27)
      at Object.onChange (node_modules/cleave.js/dist/cleave-react-node.js:344:35)
      at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:362:14)
      at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:411:16)
      at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:466:31)
      at invokeGuardedCallbackAndCatchFirstError (node_modules/react-dom/cjs/react-dom.development.js:480:25)
      at executeDispatch (node_modules/react-dom/cjs/react-dom.development.js:612:3)
      at executeDispatchesInOrder (node_modules/react-dom/cjs/react-dom.development.js:637:5)
      at executeDispatchesAndRelease (node_modules/react-dom/cjs/react-dom.development.js:743:5)
      at executeDispatchesAndReleaseTopLevel (node_modules/react-dom/cjs/react-dom.development.js:752:10)
      at forEachAccumulated (node_modules/react-dom/cjs/react-dom.development.js:724:8)
      at runEventsInBatch (node_modules/react-dom/cjs/react-dom.development.js:769:3)
      at node_modules/react-dom/cjs/react-dom-test-utils.development.js:1596:7
      at Object.batchedUpdates$1 [as unstable_batchedUpdates] (node_modules/react-dom/cjs/react-dom.development.js:24328:12)
      at node_modules/react-dom/cjs/react-dom-test-utils.development.js:1592:14
      at eventFn (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:540:11)
      at fn (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:404:37)
      at batchedUpdates$1 (node_modules/react-dom/cjs/react-dom.development.js:24328:12)
      at Object.act (node_modules/react-dom/cjs/react-dom-test-utils.development.js:1120:14)
      at act (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:404:13)
      at Object.wrapAct [as simulateEvent] (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:539:9)
      at ReactWrapper.simulateEvent (node_modules/enzyme/src/ReactWrapper.js:666:22)
      at ReactWrapper.call [as single] (node_modules/enzyme/src/ReactWrapper.js:1170:21)
      at ReactWrapper.single [as simulate] (node_modules/enzyme/src/ReactWrapper.js:665:17)
      at simulate (src/utilities/tests/enzymeUtilities.js:29:13)

This doesn’t happen when using Cleave version 1.5.10, it was definitely introduced in 1.6.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: undefined is not an object (evaluating 'object['body']')
As people pointed out in the comments, an initial render is done before componentDidMount , so that's the reason why you're getting the ......
Read more >
ERROR TypeError: undefined is not an object (evaluating ...
Ever encountered this error → ERROR TypeError: undefined is not an object (evaluating '_this.props.navigation.navigate') whilst working hard on your project?
Read more >
undefined is not an object (evaluating 'response.data')
Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'response.data'). Hi, I'm trying to make my Flash component have a level ...
Read more >
null is not an object (evaluating 'delete i[s[u]]') – Noibu
slice.call(s, 1, u).join(".") + " is not defined in this storage"); if (e.isArray ...
Read more >
TypeError undefined is not an object (evaluating 'e.target.hash ...
Hello, my client is using Log Rocket and we are seeing this error in the Divi script, any ideas what it could be?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found