このプロジェクトの特殊な点は、「新入生がHTML/CSS/JavaScriptの基本だけで開発に参加できる」ように設計されています。
- 通常のReactではJSXという特殊な記法を使いますが、このプロジェクトでは新入生は従来のHTML/CSS/JSの書き方で開発できます
TemplateComponent.jsx
をコピーするだけで新しいページが作れる- 明確に「HTMLを書く場所」と「JavaScriptを書く場所」が分かれている
- CSSはページごとにインポートする
📁 src/components/
├── TemplateComponent.jsx 👈 これをコピーして新ページを作成 (HTML / Javascript)
├── TemplateComponent.css 👈 スタイル用 (CSS)
└── pages/ 👈 作成したページはここに保存
├── Example.jsx 👈 今はサンプル(/example)
└── Example.css
# リポジトリのクローン
git clone [リポジトリURL]
cd cancel-app
# 必要なパッケージをインストール
npm install
# 開発サーバーを起動
npm run dev
これだけで開発環境の準備は完了です!
src/components/TemplateComponent.jsx
とsrc/components/TemplateComponent..css
をコピーsrc/components/pages/
の中に新しい名前でそれぞれ保存(例:HogePage.jsx
)- ファイル内の「コンポーネント名」を変更(例:
function HogePage() {
) - CSSのインポートパスを修正(例:
import './HogePage.css';
)
-
HTML: コンポーネント内の「ここからHTMLを書き始めてください」の部分を編集
return ( {/* ↓↓↓ ここからHTMLを書き始めてください ↓↓↓ */} ページタイトル コンテンツ... {/* ↑↑↑ ここまでHTMLを書いてください ↑↑↑ */} );
-
JavaScript: useEffect内の指定場所にコードを書く
useEffect(() => { // ↓↓↓ ここからJavaScriptコードを書き始めてください ↓↓↓ if (containerRef.current) { const button = containerRef.current.querySelector("#my-button"); if (button) { button.addEventListener("click", () => { alert("ボタンがクリックされました"); }); } } // ↑↑↑ ここまでJavaScriptコードを書いてください ↑↑↑ }, []);
- HTMLでは
class
ではなくclassName
を使う - DOM要素の取得は
document.getElementById
ではなくcontainerRef.current.querySelector
を使う - コードの変更は保存すると自動的にブラウザに反映される
# Firebaseパッケージをインストール
npm install firebase
src/firebase/firebase-config.js
を作成して以下のコードを追加:
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
import { getAuth } from "firebase/auth";
// Firebaseの設定情報
const firebaseConfig = {
apiKey: "YOUR_API_KEY",
authDomain: "YOUR_PROJECT.firebaseapp.com",
projectId: "YOUR_PROJECT",
storageBucket: "YOUR_PROJECT.appspot.com",
messagingSenderId: "YOUR_MESSAGING_ID",
appId: "YOUR_APP_ID",
};
// Firebaseの初期化
const app = initializeApp(firebaseConfig);
export const db = getFirestore(app);
export const auth = getAuth(app);
import { collection, addDoc, getDocs } from "firebase/firestore";
import { db } from "../firebase/firebase-config";
// データを保存する関数
async function saveCancel(cancelData) {
try {
const docRef = await addDoc(collection(db, "cancels"), cancelData);
console.log("保存成功:", docRef.id);
return docRef.id;
} catch (error) {
console.error("保存エラー:", error);
return null;
}
}
// データを取得する関数
async function getCancels() {
const cancelsSnapshot = await getDocs(collection(db, "cancels"));
const cancelsList = [];
cancelsSnapshot.forEach((doc) => {
cancelsList.push({ id: doc.id, ...doc.data() });
});
return cancelsList;
}
GitHub Pagesを使って簡単にデプロイできます:
# gh-pagesパッケージのインストール
npm install --save-dev gh-pages
{
"homepage": "https://jack-app.github.io/jackHack2025_B",
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d dist"
// 他のスクリプト...
}
}
npm run build
npm run deploy
これだけでアプリが公開されます。URLはhttps://jack-app.github.io/jackHack2025_B/
です。
デプロイは慎重にやりましょう。
頑張ろう❤️🔥