question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Elements not defined

See original GitHub issue

Hello there, and thank you for your work. I’ve follow the steps on the doc and I have these erros… 😕 I did the 2 first steps after “usage” for react.

Failed to compile

./src/js/components/modules/dashboard/Dashboard.jsx
  Line 10:6:   "loading" is not defined      no-undef
  Line 13:3:   "doSomething" is not defined  no-undef
  Line 19:10:  "Button" is not defined       react/jsx-no-undef

Search for the keywords to learn more about each error.

In my index.js

const instance = createInstance({
	urlBase: "https://stats.level-up.education/",
	siteId: 2, // optional, default value: `1`
});

ReactDOM.render(
	<MatomoProvider value={instance}>
		<Root/>
	</MatomoProvider>,
	document.getElementById('root')
);

And for the component I just took yours (in the doc).

Thank you.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jonkoopscommented, Mar 19, 2020

@GentillePlume try using this code instead:

import React from 'react'
import { useMatomo } from '@datapunt/matomo-tracker-react'

const MyComponent = () => {
  const { trackPageView, trackEvent } = useMatomo()

  // Track page view
  trackPageView()

  const handleOnClick = e => {
    // Track click on button
    trackEvent({ category: 'sample-page', action: 'click-event' })
  }

  return <button type="button" onClick={handleOnClick}>Click me</button>
}
1reaction
jonkoopscommented, Mar 19, 2020

@GentillePlume If you want to use a class component make sure to add the render() method to your component. I would reccomend to read the React documentation.

I am closing this issue as the problem seems to be resolved. Good luck with your app!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught ReferenceError: element is not defined
I have created a delete button that deletes a row from my database using jquery and ajax. when i click the button i...
Read more >
ReferenceError: Element is not defined · Issue #6610 - GitHub
The issue is that rollup removes unused code. It considers adding const Element = typeof Element === "undefined" ? function () {} :...
Read more >
ReferenceError: "x" is not defined - JavaScript - MDN Web Docs
The JavaScript exception "variable is not defined" occurs when there is a non-existent variable referenced somewhere.
Read more >
Getting javascript error: element is not defined
I am using javascript to check CSS styles. I'm getting element is not defined in below line. js.executeScript("const repeatValue = element.style ...
Read more >
CPython 3 'name element is not defined' - Revit - Dynamo Forum
I'm not a Python Pro, but i think it happens because you only use the variable “element” inside the for loop. So it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found