Question: Uppy + React, how to access uppy instance thru components ?
See original GitHub issueHi Uppy teams,
I’ve initialized one Uppy Instance in my React ./App.js
Component:
class App extends React.Component {
constructor() {
this.state.UppyInstance1 = Uppy({
id: 'UppyInstance1',
…
});
}
…
}
I would like to access this instance in sub/sub/children components of ./App.js
and manually add files to it with the uppy.addFile() method.
Do i have to pass the Uppy Instance thru props of children Coomponents, or is there an other way to do it ? @uppy/store-redux
only passes instance state, but i can’t access instance methods thru redux (for example like UppyInstance1.addFile()
).
Thanks a lot for your help !
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Introduction - Uppy
Uppy provides React components for the included UI plugins. Installation. All React components are provided through the @uppy/react package. Install from NPM: ...
Read more >uppy/react invalid prop type when refactoring ... - Stack Overflow
When I run this code i get an error of: Warning: Failed prop type: Invalid prop uppy of type Object supplied to DashboardModal...
Read more >react-dropzone
Or the wrapper component for the hook: import React from 'react' import Dropzone from 'react-dropzone' <Dropzone onDrop={acceptedFiles ...
Read more >uppy - npm
Why not use <input type="file"> ? Having no JavaScript beats having a lot of it, so that's a fair question! Running an uploading...
Read more >How to Use WordPress with React [WP REST API Tutorial]
It defines the way information is shared between programs and structures the way different components of an application will interact with each ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi Aarbel. I just had this problem and solved it the following way.
In uppyAll file where I have all my initialised Uppy instances;
In parent appContainer. I did this so that the file upload would happen in the top most container, in the attempt to ensure the upload is not broken by navigating away from a page:
Then in the child WhateverComponent I could call Uppy instance like:
Then I can upload any file in any component across the app like this:
If anyone has any better suggestions I am all ears. I actually started to ask the same question before and then luckily got it working after a lot of trial and error. I did integrated this with Uppy Redux module as well if you need me to attach that code as well. This seemed to work for me after a great deal of time / trial and error.
Hope this helps.
I had same issue, you have to choose between DocumentsPage.contextType = ReactAppContext and create ReactAppContext with a default value, or using Providers which values are set from the state.