I try to create a custom hook
const useX({name}) = () =>{
return name??"no name";
}
Then i use:
const customHook = useX();
Exist any way to create a functional component with optional props without typescript?
I try it, but get same error:
const useX({name:"DEFAULT"})
const useX({name:""})
const useX({name:{})
>Solution :
Might be there are a few syntax errors in your code. try this code:-
const useX = ({ name = "DEFAULT" } = {}) => {
return name ?? "no name";
};