Skip to content

Commit

Permalink
usestate実験
Browse files Browse the repository at this point in the history
  • Loading branch information
koma0504 committed Jun 17, 2021
1 parent 3333711 commit 2b056de
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,29 @@ import Image from "next/image";
import { Header } from "../components/Header/Header";
import { Footer } from "../components/Footer/Footer";
import { useCallback } from "react"; //再生成を防ぐ
import { useEffect } from "react";
import { useState } from "react";

export default function Home({ blog }) {
let foo = 123;
const hendleClick = useCallback((e) => {
e.preventDefault();
alert(foo);
}, []);

const [count, setCount] = useState(1);
const hendleClick = (e) => {
setCount((count) => count + 1);
};
console.log("count", count);
// useEffect(() => {
// console.log("マウント時");
// return () => {
// console.log("アンマウント時");
// };
// }, []);
return (
<div className="body">
<Header title="RATIO OBSERVER" layout="swiper" />
<main className="main">
<a href="/about" onClick={hendleClick}>
<h1>{count}</h1>
<botton href="/about" onClick={hendleClick}>
btn
</a>
</botton>

<section className="about">
<h2 className="title">ABOUT</h2>
Expand Down

1 comment on commit 2b056de

@vercel
Copy link

@vercel vercel bot commented on 2b056de Jun 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.