0

here is my GooglePicker

<GooglePicker clientId={'ClientID'}
                         developerKey={'API Key'}
                         scope={['https://www.googleapis.com/auth/drive.readonly']}
                         onChange={this.onChange}
                         multiselect={true}
                         navHidden={true}
                         authImmediate={false}
                         mimeTypes={['image/png', 'image/jpeg', 'image/jpg']}
                         viewId={'DOCS_IMAGES'}>
               <button type="button" id="pick">Pick File</button>  
            </GooglePicker>

here is my onchange function

onChange() {
       console.log("Change is logged here");
}

I am able to display the picker button and select the file from google drive. But onChange function is not being called. Please let me know the flaw in the code.

1 Answer 1

1

Try to send your onChange function like the arrow function:

<GooglePicker clientId={'ClientID'}
                         developerKey={'API Key'}
                         scope={['https://www.googleapis.com/auth/drive.readonly']}
                         onChange={(data) => this.onChange(data)}
                         multiselect={true}
                         navHidden={true}
                         authImmediate={false}
                         mimeTypes={['image/png', 'image/jpeg', 'image/jpg']}
                         viewId={'DOCS_IMAGES'}>
               <button type="button" id="pick">Pick File</button>  
            </GooglePicker>
Sign up to request clarification or add additional context in comments.

5 Comments

Great! It's working fine now. I have just started GooglePicker,But do not have much idea. And also tried a lot in internet for Googlepicket react implementation, But couldn't find anything. Could you suggest me any link or Docs for this. Thank you
Great! It's working fine now. I have just started GooglePicker,But do not have much idea. And also tried a lot in internet for Googlepicket react implementation, But couldn't find anything. Could you suggest me any link or Docs for this. Thank you
@Kishore, GooglePicker is not famous, and I see it first time, I just opened it's source and find problem. I can say they have a demo
Usually Onchange() is called in a normal way, But in this case ,it is being called with help of Arrow function. is this specific thing because of GooglePicker? or are there any special reason?
Not sure what is the data here but, when you need to call your method with a params, you can't just write onChange={this.onChange(somParam)} this function will be called without onChange, with first render, to avoiding this behavior usually used arrow func.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.