Skip to content

Instantly share code, notes, and snippets.

@YaroslavRaksha
Created September 3, 2021 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YaroslavRaksha/ce3d5875b925e4115cd12de2efeb507f to your computer and use it in GitHub Desktop.
Save YaroslavRaksha/ce3d5875b925e4115cd12de2efeb507f to your computer and use it in GitHub Desktop.
import customHook from "./customHook"
function App() {
customHook("ссылка")
const { state } = customHook();
console.log(state)
return (
<></>
);
const customHook = url => {
const [state, setState] = useState(false)
fetch(url).then((data) =>
/* допустим прилетает тру или фолс */
if(data) {
setState(true); }
if(!data) {
setState(false); }
return { state }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment