Comments (5)
You can destructure this as { loading: otherLoadingName }
and with an object you can get only the parts you need.
from useful-custom-react-hooks.
Yes, I know. Looks more common to return something more like useState()
from useful-custom-react-hooks.
I think it is really more personal preference which return method is most familiar. I generally prefer to work with objects unless I know I will be using all values returned from the function.
from useful-custom-react-hooks.
I agree with you about the return preference, and I generally prefer to return Objects. I explain how instead of why. Sorry, my fault.
The most common React hooks use arrays as returns. In this case, I think, it's more about destructuring preference and consistency between all the hooks.
It is much clearer in useTimeOut(). useAsync() is more like an edge case because it returns 3 values and if you want to use only 2 values you have to use a [value ,, loading]
and it is a bit more error-prone.
hooks/blob/f5dda2e69d51e5da52aa75f21c6e83610def5923/src/2-useTimeout/useTimeout.js#L29
In this case, this looks much more similar to useState() to me.
const [ setTimeout ] = useTimeout()
I forgot to tell you that I personally really appreciate what you do. You help me so much with your videos.
from useful-custom-react-hooks.
I appreciate the explanation. I still plan to keep the hooks as they are so they match with what I showed in the video, but if you implement these hooks in your own project you are more then welcome to modify them to your needs.
from useful-custom-react-hooks.
Related Issues (20)
- Probably not an issue HOT 1
- Bug in useArray HOT 1
- Bug in useStateWithHistory HOT 1
- Turn this repo into an npm package HOT 1
- Please add hacktoberfest tags in repo HOT 2
- useCamera HOT 1
- Create vercal support to host the project HOT 1
- useOnScreen causing issue while unmounting HOT 3
- l HOT 2
- Make useful-custom-react-hooks a npm package HOT 2
- useCookie with TypeScript HOT 1
- useContext
- Nextjs specific hooks
- useStateWithHistory return problems HOT 1
- Return as Array HOT 1
- Return as Array HOT 1
- Typescript Version? HOT 1
- useTimeout - unnecessary dependency array HOT 3
- Hook ideas HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from useful-custom-react-hooks.