jsonapi-serializer icon indicating copy to clipboard operation
jsonapi-serializer copied to clipboard

Using on React

Open jonatasdaniel opened this issue 6 years ago • 3 comments

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?

jonatasdaniel avatar Jun 08 '19 21:06 jonatasdaniel

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!

sepowitz avatar Jul 12 '19 18:07 sepowitz

@sepowitz this does not work, FYI :)

sp90 avatar Dec 19 '19 10:12 sp90

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

raoufswe avatar Mar 10 '20 10:03 raoufswe