Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$ is not defined #5975

Closed
afgarcia86 opened this issue Feb 3, 2016 · 2 comments
Closed

$ is not defined #5975

afgarcia86 opened this issue Feb 3, 2016 · 2 comments

Comments

@afgarcia86
Copy link

I have a class that is trying to do a get request in the componentDidMount function, however if I initially load a page with this component in it I get the following error. $ is not defined. I followed the example from xxx I just changed it over to ES6, perhaps I am using something improperly?

`
class NativeApp extends React.Component {

state = {
banners : {}
}

loadBanners() {
this.serverRequest = $.get('/api/banners', function (res) {
this.setState(res)
}.bind(this))
}

componentDidMount() {
this.loadBanners()
}

render() {
return (

Manually Load Banners WHY!!!

)
}
}

export default NativeApp
`

@jimfb
Copy link
Contributor

jimfb commented Feb 3, 2016

Add <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> in your header.

This is a usage question, rather than a bug in the React core. Usage questions are better answered on sites like StackOverflow, as we try to use github issues for tracking bugs in the React core. For this reason, I'm going to close out this issue, but feel free to continue the conversation on this thread or move it to StackOverflow.

@afgarcia86
Copy link
Author

Ahh... I should have known it was that simple. Sorry for wasting your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants