im a noob in React.js , and just messing around with components and event listeners , i am trying to Add eventlistener to button but it doesnt work for some reason... I tried to import elemental but that just gives a bunch of other errors , can somone please tell me how i can get this to work ? thanks
import React from 'react';
import ReactDOM from 'react-dom';
class Passiing extends React.Component {
scream() {
alert('you passed!');
}
render() {
return <Button onClick={this.scream}>Did you pass?</Button>;
}
}
ReactDOM.render(<Button />, document.getElementById('app'));
export default Passiing;
The React. js error "X is not defined react/jsx-no-undef" occurs when we forget to import a function, class or a variable in our code before using it. To solve the error, make sure to import the value before using it in your code, e.g. import {myFunc} from 'my-package' .
You will need to import Button using react-bootstrap.
import { Button} from 'react-bootstrap';
In order for the style to appear, please install bootstrap and import 'bootstrap/dist/css/bootstrap.css' and add it in index.js
To use button,
Submit
You could use the HTML5 <button>
tag for your button. If you use a capital letter for a tag in React it assumes that is a component rather than a "regular" tag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With