Skip to content

Commit

Permalink
Merge pull request #58 from SystemEngineeringTeam/48-add-customhook-f…
Browse files Browse the repository at this point in the history
…or-features-evaluate

useCrazyScoreフックの追加
  • Loading branch information
SatooRu65536 authored Nov 5, 2024
2 parents 75187b5 + 210381a commit 7812ca4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/app/(use-header)/post/_components/logic/useCrazyScore.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { useState, useEffect } from 'react';

type CrazyScore = 0 | 1 | 2 | 3;

export const useCrazyScore = () => {
const [value, setValue] = useState<CrazyScore>();

const updateValue = (newValue: CrazyScore) => {
if (newValue === value) {
setValue(undefined);
} else {
setValue(newValue);
}
};

useEffect(() => {
console.log('value:', value); // eslint-disable-line no-console
}, [value]);

return { value, updateValue };
};

0 comments on commit 7812ca4

Please sign in to comment.