elgerlambert / redux-localstorage

Store enhancer that syncs (a subset) of your Redux store state to localstorage.
MIT License
1.32k stars 107 forks source link

Importing persistState is undefined #90

Closed JulianSalomon closed 6 years ago

JulianSalomon commented 6 years ago

When I try to import redux-localstorage as follows

import persistState from 'redux-localstorage';

I get this error TypeError: redux_localstorage_1.default is not a function.

Then I tried const persistState = require('redux-localstorage'); and it worked.

The problem is that require is incompatible with Angular

ERROR in src/app/app.module.ts(11,22): error TS2304: Cannot find name 'require'.

Should I import require in the project?, There is another way to import it with import ... from ...?

Thanks in advance.

vincic commented 6 years ago

This workaround worked for me but compiler complained if you have @types/redux-localstorage installed. import * as persistState from 'redux-localstorage';

JulianSalomon commented 6 years ago

That solution worked for me too.

Thanks @vincic!