react-promise-suspense
react-promise-suspense copied to clipboard
A React hook for resolving promises with Suspense support. <1kb bundle.
Pull request name describes PR enough Working types [proof](https://www.typescriptlang.org/play?#code/MYewdgzgLgBAZgQwNYFMBKKIFcA2UBcMCYAnjALwxi44DcAUI6JLFhCgAoBOIAtgJbsKMADwBBLgHMIMFAA8oKMABMZxEgG0AugBoYGbHlkKlqoqQB8ACgAOPAe0JWAdK-5gbWKBEITpASgoLGG4+QRQRA1woCz13T29fKQg9HH44TBtiAH5Cal4AIxQuf0Ioo3JggG96GBguFCgsLjB4ZHRMaPoAXwZGeisECBIwYBgrQMqYGrq65mgYCD4UABEEKAQAZRBm4BRhIZHgKwBHLGKSQmgud0k9LMkUPKxC4tKQ+3CRa9vtYKnEKhylBarN5rAzhcrlAbmBJMIAORyBEMWYwcEwB5PKgvIpcYQABj6aIxGSgwAAFihlGsNgcAO4IfisdihBwoKxLXirdZbHZcPZ6DSQrgke4IR5afzE2ZkynU2kIZwAKxA7gmMAA9JrRABaXUwKAkGzUohqLhcBAkfok8ALH5w9L8akcCXYh3wygIgkoxhohCM5kwNicT7sTnLRXbXYoIUisWLGG3J0ut1S2hanUifWGrgUkD0tStYo8Lg9fwTIA): ```ts const fakeResult: any = null; const usePromise = (promise: (...inputs: Args) => Promise, inputs: Args, lifespan?: number = 0): Result...
Can we have an option to cleanup on unmount, something similar to this: ```js promiseCaches.push(promiseCache); useEffect(() => () => { promiseCaches = promiseCaches.filter(p => p !== promiseCache); }, []); throw...
Can we export a function to programmatically remove a cache item? The exported function should take two parameters `promiseFn` and `inputs` then we can filter the cache array to remove...
I'm working with threejs and here using usePromise to load an external model it works the first time, but not on successive use of the loader on the same resource....
Is it possible to make `usePromise` strongly typed? Currently it's ```typescript function usePromise ( promise: (...inputs: any) => any, inputs: Array, lifespan: number = 0 ): any ``` Perhaps a...
Right now we are having a global cache array. I think we should have a way to config the cache size to make sure it wont be too big and...
We need to improve the if statement in the cache check to: `if (promiseCache.promiseFn === promise && deepEqual(inputs, promiseCache.inputs))` Example of an invalid case: ```js const fn1 = () =>...