Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a0cb421

Browse files
authoredAug 6, 2024··
Automatically detect React Navigation version for examples (#1358)
1 parent bb7ba79 commit a0cb421

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+229
-222
lines changed
 

‎src/components/Pre.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useActiveVersion } from '@docusaurus/plugin-content-docs/client';
12
import { useColorMode } from '@docusaurus/theme-common';
23
import { usePluginData } from '@docusaurus/useGlobalData';
34
import MDXPre from '@theme-original/MDXComponents/Pre';
@@ -7,12 +8,12 @@ export default function Pre({
78
children,
89
'data-name': name,
910
'data-snack': snack,
10-
'data-version': version,
1111
'data-dependencies': deps,
1212
'data-lang': lang,
1313
...rest
1414
}) {
1515
const { colorMode } = useColorMode();
16+
const activeVersion = useActiveVersion();
1617
const { versions } = usePluginData('react-navigation-versions');
1718

1819
const child = React.Children.only(children);
@@ -82,6 +83,12 @@ export default function Pre({
8283
)
8384
: {};
8485

86+
const version = activeVersion?.name;
87+
88+
if (version == null || versions[version] == null) {
89+
throw new Error(`Invalid version: ${version}`);
90+
}
91+
8592
Object.assign(
8693
dependencies,
8794
Object.entries(versions[version]).reduce((acc, [key, value]) => {

‎src/plugins/react-navigation-versions.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export default function friendsPlugin(context, options) {
33
name: 'react-navigation-versions',
44
async contentLoaded({ content, actions }) {
55
const queries = {
6-
7: {
6+
'7.x': {
77
tag: 'next',
88
packages: [
99
'@react-navigation/bottom-tabs',

0 commit comments

Comments
 (0)
Please sign in to comment.