createHash icon indicating copy to clipboard operation
createHash copied to clipboard

undefined is not an object (evaluating Transform.call') React Native

Open parth-choudhary opened this issue 5 years ago • 5 comments

Getting this error in react-native using crypto-browserify.

Have setup .babelrc like this:

"plugins": [ ["babel-plugin-rewrite-require", { aliases: { crypto: 'crypto-browserify', } }]

parth-choudhary avatar Feb 28 '20 12:02 parth-choudhary

Any solution for this issue? - I am facing it too!!

My babel.config.js

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [ ["babel-plugin-rewrite-require", { aliases: { crypto: 'crypto-browserify' } } ] ]
};

tarungomile avatar Feb 15 '21 10:02 tarungomile

I also have this issue, it comes from cipher-base, a dependency, assuming we're in Node.js and that we have the stream package with a .Transform object in it -- which we don't.

fiatjaf avatar Dec 11 '21 20:12 fiatjaf

The solution is to install readable-stream from npm and create an alias using your transpiler thing (browserify, webpack, rollup etc.) from stream to readable-stream.

See https://github.com/crypto-browserify/cipher-base/issues/10#issuecomment-642491728, for example.

fiatjaf avatar Dec 11 '21 21:12 fiatjaf

Hello Everyone, I am facing the same issue ### [TypeError: undefined is not an object (evaluating 'Transform.call')] When I am trying to make the API Call:

try {
        const userId = yield select(makeSelectUserId())
        const deviceId = yield getUniqueId()
        const API_URL = `${API_BASE_URL}/users/personalization/api`
        const jsonBody = JSON.stringify({
            userId,
            deviceId,
            usecases,
            googleAdId
        })
        console.log("jsonBody------------->>>>>>>>>>>>>", jsonBody);
        const reqBodyDigest = crypto.createHmac('sha1', PERSONALIZATION_AUTH_KEY)
            .update(jsonBody)
            .digest('hex');

        const { data: { data } } = yield call(request, API_URL, {
            method: 'POST',
            header: reqBodyDigest,
            data: JSON.stringify({
                userId,
                deviceId,
                usecases,
                googleAdId
            })
        })
        console.log("Personalized Data---------------->>>>>>>>>>>>>>>>", data);
        let obj = {}
        data.forEach((value, index) => {
            obj[data[index]['widgetName']] = data[index]
        })
        yield put(personalizationDataSuccess(obj))
    }
    catch (error) {
        console.log("personalizationDataError----------->>>>>>>>>>>.", error);
        personalizationDataError(error)
    }

Can anyone please help me with this.

RahulPant1289 avatar Oct 19 '22 04:10 RahulPant1289

@RahulPant1289 the solution is right above your comment.

fiatjaf avatar Oct 19 '22 13:10 fiatjaf