7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

create-react-appで構築したReactアプリケーションでjQueryを使う

Last updated at Posted at 2016-07-25

Facebook公式のcreate-react-appコマンドを使ってReact.jsアプリを爆速で作成するを読んでさっそく試してみた。
本当に記事の通りすんなり構築できたので、jQueryも読み込んでみた。

プロジェクトのディレクトリで

npm i jquery --save

んで、index.jsに追記。

index.js

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
import $ from 'jquery';

$('#root').on('click',function(){
	console.log('クリックしたよ');
})	

ReactDOM.render(
  <App />,
  document.getElementById('root')
);

あっさり動いた。
$(function () {})っていうのはいらない。

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?