<aside>
👉 mkdir hxxhooks > cd hxxhooks > mkdir useTitle
</aside>
useTitle.js
import {useState, useEffect} from 'react';
export const useTitle = (str) => {
const [title, setTitleChange] = useState(str);
const titleChange = () => {
const titleElement = document.querySelector("title");
titleElement.innerText = title;
};
useEffect(titleChange, [title]);
return setTitleChange;
};
index.js
export { useTitle as default } from "./useTitle";
\\hxxhooks $ git init
\\hxxhooks $ cd useTitle
\\hxxhooks\\useTitle $ npm init
※ git repository : https://github.com/hxxtae/hxxhooks 로 변경
$ npm i react react-dom