27
loading...
This website collects cookies to deliver better user experience
// imported hooks to use from react
import React, { useEffect, useState } from "react";
//react function
const MyOrder = () => {
// setting react hook
const [order, setMyOrder] = useState(‘’ ”) / useState(null);
retrun(
// code contents in JSX format.
);
}
export default MyOrder;
useEffect(() => {
fetch(`http://localhost:8000/premium-autos/select-now/${id}`)
.then((res) => res.json())
.then((data) => {
console.log(data);
setOrder(data);
});
}, [id]);
import React, { useEffect, useState } from "react";
//react function and it will be our custom hook
const useAuth = ( ) => {
// setting react hook
const [userName, setUserName] = useState(‘’ ”) / useState(null);
const handleInputField = ( ) => {
// code contents
}
const handleForm = ( ) => {
// code contents
}
// returning function so that these function can be accessed in other components when custom hook will be called
retrun(
handleInputField,
handleForm
);
}
export default useAuth;