Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 893 Bytes

create-react-app.md

File metadata and controls

40 lines (29 loc) · 893 Bytes

Create React App (CRA) Guide

As a script tag

Add the script tag to your index.html.

Refer to the CDN Guide for the available URLs.

<!doctype html>
<html lang="en">
  <head>
    <script src="https://unpkg.com/react-scan/dist/auto.global.js"></script>

    <!-- rest of your scripts go under -->
  </head>
  <body>
    <!-- ... -->
  </body>
</html>

As a module import

In your project entrypoint (e.g. src/index, src/main):

// src/index.jsx

// must be imported before React and React DOM
import { scan } from "react-scan";
import React from "react";

scan({
  enabled: true,
});

Caution

React Scan must be imported before React (and other React renderers like React DOM) in your entire project, as it needs to hijack React DevTools before React gets to access it.