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

v4.4.0 does not work with latest react-native #156

Closed
leoschweizer opened this issue Jun 6, 2017 · 13 comments · Fixed by contentful/contentful-sdk-core#42
Closed

v4.4.0 does not work with latest react-native #156

leoschweizer opened this issue Jun 6, 2017 · 13 comments · Fixed by contentful/contentful-sdk-core#42

Comments

@leoschweizer
Copy link

  • Node Version: v.7.8.0
  • Npm Version: 4.2.0
  • Platform: react-native 0.44.3 on iOS 10.3
  • Package Version: contentful@4.4.0

I'm using the contentful JS-SDK in a react-native project. After upgrading from 4.3.0 to 4.4.0, the app no longer works due to contentful throwing an error on import:

Cannot read property '0' of null

in contentful.js:11297 which is the last line of this block:

        else if (
          typeof context.process == 'object' && !context.process.browser &&
          (data = context.process)
        ) {
          name = 'Node.js';
          arch = data.arch;
          os = data.platform;
          version = /[\d.]+/.exec(data.version)[0];
        }

I've downgraded to 4.3.0 and everything works as expected again.

@Khaledgarbaya
Copy link
Contributor

hi @leoschweizer,
Thanks for reporting I will check this asap.
Best,
Khaled

@leoschweizer
Copy link
Author

@Khaledgarbaya btw, the data object looks like this:

{
    "env": {
        "NODE_ENV": "development"
    }
}

so arch, platform and version are all missing.

@Khaledgarbaya
Copy link
Contributor

Khaledgarbaya commented Jun 7, 2017

Hey @leoschweizer looks like it's a problem with platform.js, will see what I can do

@Khaledgarbaya
Copy link
Contributor

let's hope this PR gets fixed bestiejs/platform.js#130
if not in the next 2 days I will maybe fork the repo and apply the patch

@Khaledgarbaya
Copy link
Contributor

Hi @leoschweizer can you get this branch of SDK-core and npm link it and test if it solves the issue for you?

@leoschweizer
Copy link
Author

@Khaledgarbaya I can't get this to work but I'm not sure if I'm doing this correctly.

Here's what I did:

  • In my app project, put contentful 4.4.0 as dependency
  • Cloned the sdk-core repository in a separate directory and checked out the fix/platform branch
  • Ran sudo npm link in the sdk-core directory
  • Ran npm link contentful-sdk-core in the app directory

But the error remains the same. Since I'm not seeing the code changes either I guess I'm missing something?

@Khaledgarbaya
Copy link
Contributor

hi @leoschweizer hmm can you clone contentful.js also and run npm build after step 4 and link contentful.js to your project ?

@leoschweizer
Copy link
Author

leoschweizer commented Jun 8, 2017

@Khaledgarbaya I did, but now I ran into this: facebook/react-native#637 - so npm link is not going to work with React Native for the time being.

@Khaledgarbaya
Copy link
Contributor

@leoschweizer 😭 ok I will try to do some tests on other platforms and release a patch version by tomorrow. Sorry about the ping pong

@axe312ger
Copy link
Collaborator

Looks like we are still blocked here since bestiejs/platform.js#130 is merged but not released yet :(

@axe312ger
Copy link
Collaborator

@leoschweizer I released https://github.com/contentful/contentful-sdk-core/releases/tag/v3.14.2 which should now work in react-native. Can you upgrade all your contentful.js (plus check that you got the latest contentful-sdk-core) and confirm if this is now working for you in react native? A small test on my local machine was promising :)

@leoschweizer
Copy link
Author

@axe312ger I can confirm that it is working for me now 👍

@axe312ger
Copy link
Collaborator

Awesome! :)

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

Successfully merging a pull request may close this issue.

3 participants