How to integrate tracking.js into React?

216 Views Asked by At

I am writing a program to scan an image for colors and identify where the colors are using pixels as X and Y values. Im using tracking.js to do this. According to the docs, its supposed to be use in browser. I spent a couple of hours creating the code, under a two <Script> tags. One to import Tracking.js and one to handle the code for it. How can I import the libraries into react? I tried importing the dependency directly but it just caused error calls, including the one below error message

Would I have to use something like onEffect() or onMount()? Thank you :)

I've tried importing the script through import tracking from "./modules/tracking-min.js", and through onEffect attempting to import a script div with the local repo of the import file. All of the code is in a single tracking.min.js file

1

There are 1 best solutions below

0
On BEST ANSWER

To use tracking.js in a React application, you may need to find a way to import the library into your application and make it work with the React component lifecycle. One way to do this is to use a third-party library that provides a React wrapper for tracking.js, or to create your own wrapper that integrates tracking.js with React. Regarding your question about using onEffect() or onMount(), these are lifecycle methods in React that are used to perform actions when a component is mounted or updated. However, they may not be directly related to importing a library like tracking.js.