-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Export 'state-upadte' event on types #4698
Comments
@Murderlon So the default-store thing also not stable now? What if I create my own store instance and pass to Uppy constructor, and then I Uppy is very great, I'm currently working on my application based on it, if I can help with this store thing, fell free to let me know. |
Stores are stable! I'm realising now the docs on custom stores and our What are you trying to achieve with |
I'm tring to implement a function useUppySelector(uppy, selector) {
const [state, setState] = useState(() => selector(uppy.getState()));
useEffect(() => {
const handler = (prevState, nextState) => {
setState(selector(nextState));
};
uppy.on(
"state-update",
handler,
);
setState(() => selector(uppy.getState()));
return () => {
uppy.off("state-update", handler);
};
}, [uppy, selector]);
return state;
} Because this hook state rely on part of uppy state, so I suppose it will not be too much useless rerender, but you are right, I will check it later. And I can also do it based on store instance. |
Coincidentally, I'm looking into improving Uppy in React this week or next week. Was also thinking of some kind of Regarding your implementation, your selector doesn't select anything yet? Hence it will update on all state changes? Perhaps you can get away with it if you |
No actually, the useUppySelector(uppyInstance, (state) => state.files) In this case, the Note this is just a prototype implementation, I suppose I will need to use |
Thanks for sharing. I'll experiment with your prototype soon to see if we can publish something like this with |
Initial checklist
Link to runnable example
No response
Steps to reproduce
When use
uppy.on('state-update')
to listen forstate-update
event, we will get type error becausestate-update
event did not exported in type declarationThis event is very useful for frameworks like react, it should be exposed.
Expected behavior
Expose
state-update
event in uppy core declaration.Actual behavior
No
state-update
event exposed in uppy core declaration.The text was updated successfully, but these errors were encountered: