세팅 2
2023. 12. 21. 15:03ㆍ개발
Custom Hook
// src/hooks/useInput.js
import React, { useState } from "react";
const useInput = () => {
// 2. value는 useState로 관리하고,
const [value, setValue] = useState("");
// 3. 핸들러 로직도 구현합니다.
const handler = (e) => {
setValue(e.target.value);
};
// 1. 이 훅은 [ ] 을 반환하는데, 첫번째는 value, 두번째는 핸들러를 반환합니다.
return [value, handler];
};
export default useInput;
Next.js 설치
npx create-next-app@latest
npm install
npm run dev
== yarn start
경로 @.
jsconfig.json
{
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}
axios hook
import axios from 'axios';
const postAxios = axios.create({
baseURL: "https://localhost:3004/posts/",
})
export default postAxios;
'개발' 카테고리의 다른 글
간단하게 json 세팅 (0) | 2023.12.29 |
---|---|
경로에 혼선이 생기면 모듈 에러가 뜬다. (0) | 2023.12.27 |
다시 시작. (0) | 2023.12.19 |
SidePj -시작 (0) | 2023.12.13 |
위치 기반 음악 공유 프로젝트 KPT (0) | 2023.12.11 |