Skip to content

Commit

Permalink
docs: Added comment with a workaround for typescript errors for Theme…
Browse files Browse the repository at this point in the history
…Provider (#164)

* Added comment with a workaround for typescript errors with older versions of React/Typescript in docs

* Added ThemeProvider to import for accuracy
  • Loading branch information
overthemike authored Aug 25, 2024
1 parent 96914f0 commit 9442fd0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/demos/ThemeProvider/TSSupport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,23 @@ export default () => (
<App />
</ThemeProvider>
);

/**
* In some instances, if you are using a previous version of React and/or Typescript,
* you may get an error like this:
*
* 'ThemeProvider' cannot be used as a JSX component.
* Its return type 'ReactNode' is not a valid JSX element.
* Type 'undefined' is not assignable to type 'Element | null'.
*
* You can fix this by either upgrading React and/or Typescript, or by overriding the
* ThemeProvider type definition like this:
*
* import { ThemeProvider, ThemeProviderProps } from 'antd-style'
* ...
* const ThemeProviderComponent = ThemeProvider as <T = any, S = any>(
* props: ThemeProviderProps<T, S>
* ) => JSX.Element
*
* and then use ThemeProviderComponent instead of ThemeProvider.
*/

0 comments on commit 9442fd0

Please sign in to comment.