quarrant / mobx-persist-store

Persist and rehydrate observable properties in mobx store.
268 stars 14 forks source link

Warning: Store does not have a valid storage adaptor #96

Closed viktorgullmark closed 10 months ago

viktorgullmark commented 1 year ago

Hey! Thanks for the great package.

Got a pretty annoying warning though after following the examples. Using latest mobx and getting the following:

image

App.tsx

configurePersistable(
  {
    storage: localforage,
    stringify: false,
  },
  { delay: 200, fireImmediately: false },
);

const App = () => {
  return (
    <HashRouter>
      <Routes>
        <Route path='/' index={true} element={Login()} />
        <Route path='/dash' element={Dashboard()} />
      </Routes>
      <MobxRouter />
    </HashRouter>
  );
};

AuthStore.ts

export default class AuthStore {
  user?: UserDomain;
  code = "";
  authState = uuidv4();

  constructor(private rootStore: RootStore) {
    makeAutoObservable(this);

    makePersistable(this, {
      name: "AuthStore",
      properties: ["user"],
    });
  }

It seems strange that these properties are required on a store, am I missing something or is there a way to remove the warning?

Cheers!

jwoyame commented 1 year ago

This issue may be resolved by #104.