contentful.js: Can't import contentful in to react native project

Hi there,

I am extremely excited about using contentful for my project, but I can’t get the JS library to work in a react-native project.

I get the following error: screen shot 2016-10-10 at 16 10 44

I have tried the following approaches:

import contentful from 'contentful'; 
// or
var contentful = require('contentful');

You can reproduce the bug by going to this repo and following the steps I have provided.

Help would be greatly appreciated.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

@Khaledgarbaya do you know how can we add TS typings/intellisense when importing from contentful/dist/contentful.browser.min.js?

For reference, we have this workaround in the troubleshooting section https://github.com/contentful/contentful.js#troubleshooting

@andreipfeiffer @Khaledgarbaya The workaround might include this in the TypeScript section:

import {EntryCollection, ContentfulClientApi} from 'contentful';
// @ts-ignore
import {createClient} from 'contentful/dist/contentful.browser.min.js';

const client: ContentfulClientApi = createClient({
    space: Env.CONTENTFUL_SPACEID,
    accessToken: Env.CONTENTFUL_TOKEN,
  });