-
Notifications
You must be signed in to change notification settings - Fork 611
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
React-native - "TypeError: Undefined is not a function" #6933
Comments
Hi @harshit-infogen - thanks for reaching out. We have this aws-sdk-js-tests repo with minimal reproduction for issues like this and I wasn't able to reproduce this error by running in that repo. Feel free to quickly spin up to help narrow down the root cause.
|
Hey @aBurmeseDev , thank your for looking into it. Here are my findings on your questions -
Let me know if you need more information from my side! |
Appreciate the additional info! I have come across this error a few times myself with RN and most of the times the root cause happens to be where I'm attempting to call a value as a function but value is undefined. Can you try this? try {
const command = new PutObjectCommand(params);
const response = await s3Client.send(command);
console.log('S3 upload response:', response); // Add this log
// Only create location if upload was successful
if (response && response.$metadata?.httpStatusCode === 200) {
const location = `https://${S3_BUCKET}.s3.${REGION}.amazonaws.com/${uniqueKey}`;
return location;
} else {
console.warn('Upload response not as expected:', response);
return null;
}
} |
@aBurmeseDev I tried to implement the above code, but I am still getting the same error.
I received the S3 command response, but not the S3 upload response. In the end, it goes to the catch statement and returns the same error: “TypeError: Undefined is not a function”. Here is the S3 command response -
|
Hi @aBurmeseDev, any update on the issue? |
Hi @harshit-infogen - I haven't been able to reproduce this on my end using our test-repo which includes minimal reproduction for all environments including React Native. Could you quickly spin up the test repo and maybe run your code in there? |
Checkboxes for prior research
Describe the bug
Recently, we encountered an error in our React-native application while attempting to upload a file to our S3 bucket using the
.send()
function. The error message displayed was “TypeError: Undefined is not a function.”Regression Issue
SDK version number
"@aws-sdk/client-s3": "^3.633.0"
Which JavaScript Runtime is this issue in?
React Native
Details of the browser/Node.js/ReactNative version
"react-native": "^0.71.1", "react": "18.2.0", node - v18.20.2
Reproduction Steps
We are directly uploading the file to the S3 bucket from the client side in our React Native application. Additionally, we are utilizing the “react-native-document-picker” library to enable users to select files from their device. Below is our React Native code:
Imports:
import {PutObjectCommand, S3Client} from '@aws-sdk/client-s3';
import DocumentPicker from 'react-native-document-picker';
import {v4 as uuidv4} from 'uuid';
Function:
Observed Behavior
Brief History
We implemented this code seven months ago. However, we have recently encountered an issue (since two to three weeks ago).
Initially, the issue was with the “smithy-client” component (attached screenshot).
To address the build issue, I incorporated the Babel plugin
@babel/plugin-transform-class-static-block
into my Babel configuration. This modification successfully resolved the build issue. However, upon attempting to upload the modified file, I encountered an error message indicating that “undefined is not a function.”Expected Behavior
The
send()
function should function as intended, and the file should be successfully uploaded to the S3 bucket from our React Native application.Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: