This is a continuation of an previous issue to add support for the BigInt data type in React DevTools.

Original PR https://github.com/facebook/react/pull/17233 (merged)

This happens when you try to copy a BigInt value to clipboard via React DevTools.

![](https://image.prntscr.com/image/c4SnNIPXR1GlSXIt49FOlw.png)

Would @nutboltu mind taking a look?

```
backend.js:1 Uncaught TypeError: Do not know how to serialize a BigInt
    at JSON.stringify (<anonymous>)
    at c (backend.js:1)
    at Object.copyElementPath (backend.js:6)
    at t.<anonymous> (backend.js:6)
    at t.r.emit (backend.js:6)
    at backend.js:32
    at t (backend.js:8)
c @ backend.js:1
copyElementPath @ backend.js:6
(anonymous) @ backend.js:6
r.emit @ backend.js:6
(anonymous) @ backend.js:32
t @ backend.js:8
postMessage (async)
(anonymous) @ contentScript.js:1
<./app-insights/app-insights>:50 Uncaught TypeError: Cannot read property 'message' of null
    at trackError (<./app-insights/app-insights>:50)
    at eval (<./app-insights/app-insights>:22)
trackError @ <./app-insights/app-insights>:50
eval @ <./app-insights/app-insights>:22
setTimeout (async)
eval @ <./app-insights/app-insights>:21
error (async)
initAppInsights @ <./app-insights/app-insights>:17
main @ VM70658 client>:101
main @ ./../../../node_modules/@tessin/tcm/lib/dev/boot-loader:31
async function (async)
main @ ./../../../node_modules/@tessin/tcm/lib/dev/boot-loader:27
(anonymous) @ 219:3435
backend.js:1 Uncaught TypeError: Do not know how to serialize a BigInt
    at JSON.stringify (<anonymous>)
    at c (backend.js:1)
    at Object.copyElementPath (backend.js:6)
    at t.<anonymous> (backend.js:6)
    at t.r.emit (backend.js:6)
    at backend.js:32
    at t (backend.js:8)
c @ backend.js:1
copyElementPath @ backend.js:6
(anonymous) @ backend.js:6
r.emit @ backend.js:6
(anonymous) @ backend.js:32
t @ backend.js:8
postMessage (async)
(anonymous) @ contentScript.js:1
<./app-insights/app-insights>:50 Uncaught TypeError: Cannot read property 'message' of null
    at trackError (<./app-insights/app-insights>:50)
    at eval (<./app-insights/app-insights>:22)
trackError @ <./app-insights/app-insights>:50
eval @ <./app-insights/app-insights>:22
setTimeout (async)
eval @ <./app-insights/app-insights>:21
error (async)
initAppInsights @ <./app-insights/app-insights>:17
main @ VM70658 client>:101
main @ ./../../../node_modules/@tessin/tcm/lib/dev/boot-loader:31
async function (async)
main @ ./../../../node_modules/@tessin/tcm/lib/dev/boot-loader:27
(anonymous) @ 219:3435
backend.js:1 Uncaught TypeError: Do not know how to serialize a BigInt
    at JSON.stringify (<anonymous>)
    at c (backend.js:1)
    at Object.copyElementPath (backend.js:6)
    at t.<anonymous> (backend.js:6)
    at t.r.emit (backend.js:6)
    at backend.js:32
    at t (backend.js:8)
c @ backend.js:1
copyElementPath @ backend.js:6
(anonymous) @ backend.js:6
r.emit @ backend.js:6
(anonymous) @ backend.js:32
t @ backend.js:8
postMessage (async)
(anonymous) @ contentScript.js:1
<./app-insights/app-insights>:50 Uncaught TypeError: Cannot read property 'message' of null
    at trackError (<./app-insights/app-insights>:50)
    at eval (<./app-insights/app-insights>:22)
```
/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */
import {copy} from 'clipboard-js';
import {dehydrate} from '../hydration';
import type {DehydratedData} from 'react-devtools-shared/src/devtools/views/Components/types';
export function cleanForBridge(
  data: Object | null,
  isPathWhitelisted: (path: Array<string | number>) => boolean,
  path?: Array<string | number> = [],
): DehydratedData | null {
  if (data !== null) {
    const cleanedPaths = [];
    const unserializablePaths = [];
    const cleanedData = dehydrate(
      data,
      cleanedPaths,
      unserializablePaths,
      path,
      isPathWhitelisted,
    );
    return {