Comments (2)
I think a "keyword" could be kind of cool too. Another thing to consider is that some hooks accept more than one function. We need to gather some function signatures of hooks in the wild to determine the best approach.
import { auto } from 'hooks.macro'
customHook(() => {
foo()
bar()
}, () => {
baz()
}, auto)
customHook(() => {
foo()
bar()
}, () => {
baz()
}, [foo, bar, baz])
from hooks.macro.
I have taken a look at how hooks in the wild and this was a more common use case than having all dependencies in one array:
useCustomHook(funcA, depsA, funcB, depsB)
Maybe a more specific macros would be better? (as this is hard generalize)
import { injectAfterEach, injectAfterAll, skip } from 'hooks.macro'
injectAfterEach(useCustomHook(funcA, funcB, skip(cleanup)))
What do you think? Alternately, auto()
could just collect dependencies for the preceeding function as in useCustomHook(funcA, auto, funcB, auto)
.
from hooks.macro.
Related Issues (16)
- Extract indirect dependencies
- Create a debug/trace facility
- Create an escape hatch HOT 2
- Rules for property accesses HOT 9
- Bail out on constants HOT 1
- Error/warn on known non-invariants
- TypeScript support HOT 2
- Do not inject setState/ref into dependencies HOT 7
- State values with unused setters are known to be static (if const)
- Memoized values with empty inputs array are known to be static
- Known static return value from react-redux hook HOT 1
- useAutoUpdateEffect HOT 2
- Not adding dynamic components to dependencies HOT 3
- Feature request: debugChangedDependencies HOT 2
- Support React 17? HOT 5
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 hooks.macro.