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)
```
return value;
  }
  const key = path[index];
  const updated = Array.isArray(obj) ? obj.slice() : {...obj};
  
  updated[key] = copyWithSet(obj[key], path, value, index + 1);
  return updated;
}
export function serializeToString(data: any): string {
  const cache = new Set();
  
  return JSON.stringify(data, (key, value) => {
    if (typeof value === 'object' && value !== null) {
      if (cache.has(value)) {
        return;
      }
      cache.add(value);
    }
    return value;
  });
}