Skip to content
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: undefined is not a function (evaluating 'Namespace.extend(Type)') #560

Closed
vanekt opened this issue Dec 15, 2016 · 8 comments
Closed

Comments

@vanekt
Copy link

vanekt commented Dec 15, 2016

protobuf.js version: <6.1.0>

How to reproduce

Just import protobuf.js in ReactNative:

import Protobuf from 'protobufjs'

After rebuild the app it shows:

undefined is not a function (evaluating 'Namespace.extend(Type)')

<unknown>
type.js:8

loadModuleImplementation
require.js:170

guardedLoadModule
require.js:122

_require
require.js:106

<unknown>
namespace.js:9

loadModuleImplementation
require.js:170

guardedLoadModule
require.js:122

_require
require.js:106

<unknown>
root.js:4

loadModuleImplementation
require.js:170

guardedLoadModule
require.js:122

_require
require.js:106

<unknown>
parse.js:5

loadModuleImplementation
require.js:170

guardedLoadModule
require.js:122

_require
require.js:106

<unknown>
index.js:78

loadModuleImplementation
require.js:170

guardedLoadModule
require.js:122

_require
require.js:106

<unknown>
index.android.js:4

loadModuleImplementation
require.js:170

guardedLoadModule
require.js:122

_require
require.js:106

global code
require-0.js:1
@dcodeIO
Copy link
Member

dcodeIO commented Dec 15, 2016

Relevant line

Unfortunately, I have practically no experience with React Native, so I have to guess:

  1. The sources make heavy use of cyclic require calls, which might be causing errors in non-node environments
  2. This might be an issue with the extend implementation

One possible workaround could be to use a prebuilt bundle from dist/. These are made for browser environments, though, and do not really support require / import.

If you have additional information or an idea, let me know!

@dcodeIO
Copy link
Member

dcodeIO commented Dec 15, 2016

This now moved the extend implementation around which might or might not help with your issue, depending on what exactly is failing where. Please give it a try.

If this doesn't resolve your issue, yet, a more general approach could still be examined.

@vanekt
Copy link
Author

vanekt commented Dec 15, 2016

Unfortunately this does not solve the problem

@dcodeIO
Copy link
Member

dcodeIO commented Dec 15, 2016

Please try again. If it raises another error now, please paste it here.

@vanekt
Copy link
Author

vanekt commented Dec 15, 2016

It works! Great, thank you!

@dcodeIO
Copy link
Member

dcodeIO commented Dec 15, 2016

Feel free to reopen if necessary!

@dcodeIO dcodeIO closed this as completed Dec 15, 2016
@develand
Copy link

develand commented Mar 2, 2017

Can anyone confirm if this works with react-native?

@vanekt
Copy link
Author

vanekt commented Mar 2, 2017

The 6.5.0 version works fine with React Native

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants