aidenybai / aidenybai/react-scan

Conditionally enable react-scan

Abierto
#47 11 comentarios 4 reacciones 1 asignado Reclamado por @pivanov Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
21.8k
Forks
390
Merge medio
23 min
PR fusionados (30 d)
1

Descripción

## Question

Hi there 👋, the README suggests the following to use `react-scan` programmatically:
```
import { scan } from 'react-scan'; // import this BEFORE react
import React from 'react';

if (typeof window !== 'undefined') {
scan({
enabled: true,
log: true, // logs render info to console (default: false)
});
}
```

However, if we want to only load `react-scan` in local builds, and allow for easy enabling and disabling, is that possible? If so, how?

## Ideal API
My ideal API would be something like this:
```
import React from 'react';

function enableScanning() {
import('react-scan').then(({ scan }) => {
scan({
enabled: true,
log: true,
});
});
}

const AdminPanel = () => {
return (
...
Enable React Scan
Disable React Scan
...
)
}
```

But given the comment about `react-scan` needing to be imported before `react`, it seems like that won't be possible. Is that accurate?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.