Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export default react component #48

Open
basselalsayed opened this issue Jul 23, 2022 · 0 comments
Open

export default react component #48

basselalsayed opened this issue Jul 23, 2022 · 0 comments

Comments

@basselalsayed
Copy link

basselalsayed commented Jul 23, 2022

Yo, tried to submit a pr but I have no permissions so leaving this here since it's what worked for me:

replace client.d.ts with the followng:

// https://github.com/facebook/create-react-app/blob/0ee4765c39f820e5f4820abf4bf2e47b3324da7f/packages/react-scripts/lib/react-app.d.ts#L47-L56

declare module '*.svg' {
  import * as React from 'react'

  export const ReactComponent: React.FunctionComponent<
    React.SVGProps<SVGSVGElement> & { title?: string }
  >

  export default ReactComponent
}

not sure if there is a way to make this conditional based on the exportDefault config option I'm afraid, that would be nicer..

maybe include both? my typescript doesn't seem to mind:

declare module '*.svg' {
  import * as React from 'react'

  export const ReactComponent: React.FunctionComponent<
    React.SVGProps<SVGSVGElement> & { title?: string }
  >
  export default ReactComponent
}

declare module '*.svg' {
  import * as React from 'react'

  export const ReactComponent: React.FunctionComponent<
    React.SVGProps<SVGSVGElement> & { title?: string }
  >
  const src: string;
  export default src;
}

I understand now why the other plugins have the ?component and ?url options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant