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

Using on React #204

Open
jonatasdaniel opened this issue Jun 8, 2019 · 3 comments
Open

Using on React #204

jonatasdaniel opened this issue Jun 8, 2019 · 3 comments

Comments

@jonatasdaniel
Copy link

I'm trying to use the lib on React with
const JSONAPIDeserializer = require('jsonapi-serializer').Deserializer;
and then
new JSONAPIDeserializer.name({}).deserialize(data)

but I'm getting
./node_modules/jsonapi-serializer/index.js Module not found:

I'm adding the library with yarn add jsonapi-serializer.

What am I doing wrong?

@sepowitz
Copy link

hey @jonatasdaniel in your React project you could import this library using the ES Module import syntax:

So for the example above you might do:
import { Deserializer } from 'jsonapi-serializer';

Hope that helps!

@sp90
Copy link

sp90 commented Dec 19, 2019

@sepowitz this does not work, FYI :)

@raoufswe
Copy link

raoufswe commented Mar 10, 2020

you can use import instead of require and the library should work just fine.

if anyone is still wondering about this, I made a small demo you may all refer to.

codesandbox

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

No branches or pull requests

4 participants