react-countries-flags
Advanced tools
Comparing version 1.3.5 to 1.3.6
{ | ||
"name": "react-countries-flags", | ||
"version": "1.3.5", | ||
"version": "1.3.6", | ||
"main": "./dist/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -5,3 +5,3 @@ # react-countries-flags | ||
A simple React component for displaying country flags in various operating systems. | ||
A simple React component for displaying country flags in various operating systems. | ||
@@ -26,7 +26,7 @@ ## Installation | ||
const App = () => { | ||
return ( | ||
<div className="App"> | ||
<ReactCountriesFlags isoCode = 'am'/> | ||
</div> | ||
); | ||
return ( | ||
<div className="App"> | ||
<ReactCountriesFlags isoCode='am'/> | ||
</div> | ||
); | ||
} | ||
@@ -40,6 +40,6 @@ | ||
for example | ||
for example | ||
```javascript | ||
<ReactCountriesFlags isoCode = {'am'} alt = {'flag'} width = {50} height = {30}/> | ||
<ReactCountriesFlags isoCode={'am'} alt={'flag'} width={50} height={30}/> | ||
``` | ||
@@ -53,8 +53,8 @@ | ||
| Prop name | Type | Default value | Description | | ||
| --------- | ------ | ------------- | ---------------------------------------------- | | ||
| `isoCode` | string | none | The ISO code for the country's flag | | ||
| `alt` | string | `"flag"` | The alt text for the flag | | ||
| `width` | number | `25` | The width of the flag in pixels | | ||
| `height` | number | `15` | The height of the flag in pixels | | ||
| Prop name | Type | Default value | Description | | ||
|-----------|--------|---------------|-------------------------------------| | ||
| `isoCode` | string | none | The ISO code for the country's flag | | ||
| `alt` | string | `"flag"` | The alt text for the flag | | ||
| `width` | number | `25` | The width of the flag in pixels | | ||
| `height` | number | `15` | The height of the flag in pixels | | ||
@@ -66,1 +66,36 @@ This package should work on all operating systems that support React. | ||
https://en.wikipedia.org/wiki/ISO_3166-2 | ||
# TypeScript Compatibility | ||
## Usage with TypeScript | ||
If you encounter type-related issues when using react-countries-flags with TypeScript, follow these steps to address potential problems: | ||
1. Create TypeScript Declaration File: | ||
Create a new TypeScript declaration file, e.g., react-countries-flags.d.ts, in the root directory of your project. | ||
Add the following content to the declaration file: | ||
```javascript | ||
declare module 'react-countries-flags' { | ||
import React from 'react'; | ||
const ReactCountriesFlags: React.ComponentType<{ | ||
isoCode?: string; | ||
alt?: string; | ||
width?: number; | ||
height?: number; | ||
}>; | ||
export default ReactCountriesFlags; | ||
} | ||
``` | ||
2. Include Declaration File in TypeScript Configuration: | ||
Update your tsconfig.json file to include the declaration file by adding it to the "include" section: | ||
```javascript | ||
{ | ||
"compilerOptions": { | ||
// your compiler options... | ||
}, | ||
"include": [ | ||
"react-countries-flags.d.ts" // or the name of your TypeScript declaration file | ||
] | ||
} | ||
``` |
324928
96