Giter VIP home page Giter VIP logo

Comments (5)

mattrothenberg avatar mattrothenberg commented on June 14, 2024

FWIW, I'm using this on a Next.js project, and was able to circumvent this error by including import 'isomorphic-fetch' in all of my connected components.

from react-refetch.

KristerV avatar KristerV commented on June 14, 2024

hmm, you didn't even get the Request error? Interesting. I'll try this again at one point. For now I was forced to move back to simply using await fetch().

@mattrothenberg Could you post a gist of your component? I do wonder how you've set everything up in terms of component functions and stuff. An example in the next.js repo under examples/ would be extra king, but too much work for me to ask you :D

from react-refetch.

mattrothenberg avatar mattrothenberg commented on June 14, 2024

Nope, no more request errors. As long as I include the following (in any connected component), I seem to be OK.

// UserList.jsx

import 'isomorphic-fetch'
import { connect } from 'react-refetch'

const UserList = () => <div>...</div>

export default connect(props => ({
  usersFetch: `/api/users/`
}))(UserList)

from react-refetch.

KristerV avatar KristerV commented on June 14, 2024

Okay. Since my import was import fetch from 'isomorphic-unfect' I'll close the issue for now and open it again if following your example doesn't work for me. thanks! :)

from react-refetch.

tkvw avatar tkvw commented on June 14, 2024

I actually came across the same issue today. You need Request and fetch on the global state for react-refetch to work on SSR. I don't use react-refetch on the server, because I need user credentials to make authenticated requests and I'm not going to implement a proxy for this. So my solution is very simple, I created a blocking ssr hoc:

// connect.js
import { connect } from "react-refetch";
const BlockSsr = Component => () => null;
export default (...args) => (process.browser ? connect(...args) : BlockSsr);

from react-refetch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.