Skip to content

Example in README cannot be compiled in TypeScript #243

@kenkoooo

Description

@kenkoooo

Hi, I tried to compile the following example in 4.0.0-0 in TypeScript, which is in README, but I couldn't compile it.

import { connect, PromiseState } from "react-refetch";

interface Props {
  fooFetch: PromiseState<{}>;
  barFetch: PromiseState<{}>;
}

export default connect<{}, Props>(() => ({
  fooFetch: {
    url: `/foos/1`,
    andThen: foo => ({
      barFetch: `/bar-for-foos-by-id/1`
    })
  }
}))(() => {
  return <a>a</a>;
});

I fixed it like the following it can be compiled.

import { connect, PromiseState } from "react-refetch";

interface Props {
  fooFetch: PromiseState<{}>;
  barFetch: PromiseState<{}>;
}

export default connect<{}, Props>(() => ({
  fooFetch: {
    url: `/foos/1`,
    andThen: foo => ({
      fooFetch: { value: foo },
      barFetch: `/bar-for-foos-by-id/1`
    })
  },
  barFetch: { value: null }
}))(() => {
  return <a>a</a>;
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions