(React-Native) undefined is not a constructor evaluating 'new FormData()'

typeerror: undefined is not an object react-native
undefined is not a constructor react
webpack_imported_module is not a constructor
typeerror: is not a constructor jest
is not a constructor typescript
undefined is not a constructor evaluating new_reactnavigation stacknavigator
object is not a constructor react-native redux
is not a constructor angular 6

for the past 2 days I struggled with this problem and can't figure it out. I don't understand this error. this is my code:

try{
var formData = new FormData();
} catch (error) {
console.error('FormData ERROR', error);
}

and this is the error:

017-06-21 13:49:02.761 [error][tid:com.facebook.React.JavaScript] 'FormData ERROR', { [TypeError: undefined is not a constructor (evaluating 'new FormData()')] line: 98419, column: 36, sourceURL: 'http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false' }

Do i have to add support for FormData in ReactNative 0.45.0? please help

I got into this problem as well and that's because I have imported them on top. If you have done like what I did:

import { FormData } from 'react';

or

import { FormData } from 'react-native';

Just remove "FormData" from your imports and it will work like magic. FormData doesn't have to be imported for it to be working.

TypeError: undefined is not a constructor (evaluating 'new , I'm trying to update my Build a React Native App and Authenticate with OAuth 2.0 article to use react-native-app-auth@2.2.0 and having issues. undefined is not a constructor (evaluating 'new _reactNativeAudioToolkit.Player.play('1.m4a')') Sign up for free to join this conversation on GitHub . Already have an account?

The error says that you are FormData is undefined. Since it is not part of react native, you probably have to download it from npm.

npm install --save form-data

Then import it at the top of your file

import FormData from 'form-data';

(React-Native) undefined is not a constructor evaluating 'new , I got into this problem as well and that's because I have imported them on top. If you have done like what I did: import { FormData } from 'react';. Hi, we are working on RN Ethereum starter and just had the same issue with import of ethereumjs-wallet lib. Adding one line with "require("crypto")" above the import fixed the problem.

I think I got it.

First of all, I found something (don't know from where i had these "tips") in my index.ios.js and removed them

// const _XHR = GLOBAL.originalXMLHttpRequest ?  
//     GLOBAL.originalXMLHttpRequest :           
//     GLOBAL.XMLHttpRequest                     

// XMLHttpRequest = _XHR;

// // FormData = global.originalFormData;

Then I found out that my debugger (Chrome or RNDebugger) messed with my network requests and that was bad for multipart image object. (strange?!)

finally i got it working with this code:

var fdObject = new FormData();
fdObject.append('avatar', {uri: PicturePath, name: 'avatar.jpg', type: 'image/jpg'});
options.method = POST;
options.headers['Content-Type'] = 'multipart/form-data';
options.body = fdObject;
fetch("http://api.com/post-my-image", options);

TypeError: "x" is not a constructor, The JavaScript exception "is not a constructor" occurs when there was an attempt to use an object or a variable as a constructor, but that object� When I use ListView to show my data, a question occur to me. it throws Undefined is not an object (evaluating 'dataSource.rowIdentities'). Here is my code.

if

import { FormData } from 'react-native';

didn't help then you can try to import directly:

import FormData from 'react-native/Libraries/Network/FormData';

TypeError: undefined is not a constructor(evaluating , undefined is not a constructor(evaluating 'new_reactNativeSensors.default. from 'react-native'; import ReactNativeSensors from "react-native-sensors";� Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.Provide details and share your research! But avoid …. Asking for help, clarification, or responding to other answers.

TypeError: undefined is not a constructor (evaluating 'new , undefined is not a constructor (evaluating 'new _reactNativeSensors. trying to import {Accelerometer} from the react-native-sesors library. When I try to press my button to call the addData function, I get this error: undefined is not an object (evaluating this.state.name). On load of the app, my state variables seem to be loading just fine into the <Text/> areas: But when I submit this is what shows: When I change the body of the fetch to be something like

ReactJS TypeError "not a constructor" on running a component with , The package is outdated. We moved it to another place. Please add as dependency @carto/carto.js instead of carto.js and substitute it in� When I open it on Expo, I get the error: "undefined is not an object (evaluating 'this.props.navigation.navigate)'". Any help? It's a bit frustrating that the example from the documentation does not work :) Thank you in advance! Fred. import React from 'react'; import {AppRegistry, Button, Text, View,} from 'react-native';

Top 10 JavaScript errors from 1000+ projects (and how to avoid them), We'll pick React, but the same principles of improper initialization also apply to Angular, TypeError: 'undefined' is not an object (evaluating Any JS code that executes and deals with DOM elements should execute after the� undefined is not a constructor (evaluating 'brands.includes(brand)') And lots n lots more. It seems array proto methods aren't working as expected. Using.

Comments
  • FormData is undefined, can you make sure that the object exists in your code?
  • @D-reaper how do i do that? FormData i think is included in react-native / libraries / network
  • console.log(FormData). If it is undefined, then you just have to make sure that you include it in your code.
  • after console.log(FormData) i get undefined. i tried import { FormData } from 'react-native'; but still no luck
  • @Cristi Milea check out my answer if you haven't got the issue resolved. Thanks!
  • i tried with this library and couldn't make it work on react-native
  • and also found out that FormData comes with RN github.com/facebook/react-native/blob/master/Libraries/Network/…