blitz-js / babel-plugin-superjson-next

Automatically transform your Next.js Pages to use SuperJSON
MIT License
125 stars 15 forks source link

create `deserializeProps` utility #94

Closed italodeandra closed 2 years ago

italodeandra commented 2 years ago

Fixes #93

This PR is for exporting this new deserializeProps utility that can be used for deserializing the props on _app.tsx file.

Example:

import { deserializeProps } from "babel-plugin-superjson-next";
const { dehydratedState, ...deserializedProps } = deserializeProps(pageProps);

return (
  <QueryClientProvider client={queryClient}>
    <Hydrate state={dehydratedState}>
      <Component {...deserializedProps} />
    </Hydrate>
  </QueryClientProvider>
);
Skn0tt commented 2 years ago

published in v0.4.0

Skn0tt commented 2 years ago

@allcontributors add @italodeandra for bug, code

allcontributors[bot] commented 2 years ago

@Skn0tt

I've put up a pull request to add @italodeandra! :tada:

italodeandra commented 2 years ago

@Skn0tt To use the function I need to import like this import { deserializeProps } from "babel-plugin-superjson-next/dist/tools".

Is the babel-plugin-superjson-next/dist/tools expected? Is it possible to change to babel-plugin-superjson-next/tools? There's no actual gain on it, just my OCD screaming so you can ignore if too much trouble.