Skip to content

Commit 9dc732a

Browse files
docs: add react native compatibility table
1 parent 31ecc4e commit 9dc732a

3 files changed

Lines changed: 77 additions & 1 deletion

File tree

docs/docs/misc/compatibility.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ installing.
2020

2121
## Supported React Native versions
2222

23-
(compatibility table here)
23+
The table assumes you're using the latest patch of each library minor version.
24+
25+
<EnrichedHtmlCompatibility />
2426

2527
## Platform differences
2628

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { No, Version, Yes } from './index';
2+
3+
const REACT_NATIVE_VERSIONS = [
4+
'0.80',
5+
'0.81',
6+
'0.82',
7+
'0.83',
8+
'0.84',
9+
'0.85',
10+
'0.86',
11+
'0.87',
12+
];
13+
14+
const LIBRARY_VERSIONS = [
15+
{ version: 'nightly', supportedFrom: '0.81', supportedTo: '0.86' },
16+
{ version: '1.1.x', supportedFrom: '0.81', supportedTo: '0.86' },
17+
{ version: '1.0.x', supportedFrom: '0.81', supportedTo: '0.85' },
18+
] as const;
19+
20+
function isSupported(
21+
reactNativeVersion: string,
22+
supportedFrom: string,
23+
supportedTo: string,
24+
) {
25+
return (
26+
reactNativeVersion.localeCompare(supportedFrom, undefined, {
27+
numeric: true,
28+
}) >= 0 &&
29+
reactNativeVersion.localeCompare(supportedTo, undefined, {
30+
numeric: true,
31+
}) <= 0
32+
);
33+
}
34+
35+
export default function EnrichedHtmlCompatibility() {
36+
return (
37+
<div className="compatibility">
38+
<table>
39+
<thead>
40+
<tr>
41+
<th></th>
42+
{REACT_NATIVE_VERSIONS.map(version => (
43+
<th key={version}>{version}</th>
44+
))}
45+
</tr>
46+
</thead>
47+
<tbody>
48+
{LIBRARY_VERSIONS.map(({ version, supportedFrom, supportedTo }) => (
49+
<tr key={version}>
50+
<td>
51+
<Version version={version} />
52+
</td>
53+
{REACT_NATIVE_VERSIONS.map(reactNativeVersion => (
54+
<td key={reactNativeVersion}>
55+
{isSupported(
56+
reactNativeVersion,
57+
supportedFrom,
58+
supportedTo,
59+
) ? (
60+
<Yes />
61+
) : (
62+
<No />
63+
)}
64+
</td>
65+
))}
66+
</tr>
67+
))}
68+
</tbody>
69+
</table>
70+
</div>
71+
);
72+
}

docs/src/theme/MDXComponents.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Indent from '@site/src/components/Indent';
99
import Row from '@site/src/components/Row';
1010
import Grid from '@site/src/components/Grid';
1111
import { Yes, No, Version, Spacer } from '@site/src/components/Compatibility';
12+
import EnrichedHtmlCompatibility from '@site/src/components/Compatibility/EnrichedHtmlCompatibility';
1213
import { Badges } from '@swmansion/t-rex-ui';
1314

1415
export default {
@@ -26,5 +27,6 @@ export default {
2627
No,
2728
Version,
2829
Spacer,
30+
EnrichedHtmlCompatibility,
2931
Badges,
3032
};

0 commit comments

Comments
 (0)