francisconeves97 / react-google-forms-hooks

Build a UI for your Google Forms using React.
https://francisconeves97.github.io/react-google-forms-hooks/
32 stars 10 forks source link

Remove dependencies #9

Closed dohomi closed 2 years ago

dohomi commented 2 years ago

This is the code I am using right now. Works flawlessly.

This could be applied to the useGoogleForm hook as well and then the dependency could be removed.

Let the user decide which fetch fallback they would like to use.

francisconeves97 commented 2 years ago

Hey @dohomi! That contribution looks great 🙏

There were only a few problems running the unit tests.

Since that script is meant to run on the server side wouldn't we need to add the node-fetch dependency first? I think we might have to split the lib into client/server side before doing this change, not sure if adding the node-fetch dependency will mess up the build

dohomi commented 2 years ago

@francisconeves97 just use isomorphic-unfetch like its described here: https://www.npmjs.com/package/isomorphic-unfetch#usage

import 'isomorphic-unfetch'; // on top of both, client and server once

This is how NextJS for example makes fetch calls on server/client automatically polyfilled

dohomi commented 2 years ago

The idea is, that both client and server will use this function. so you can import it as well inside of the userGoogleForm hook. Currently you are writing the function 2 times

dohomi commented 2 years ago

11 is a better PR