forked from nodejs/nodejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
25 lines (21 loc) · 676 Bytes
/
index.tsx
File metadata and controls
25 lines (21 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { useId } from 'react';
import Select from '#ui/Common/Select';
import type { StatelessSelectProps } from '#ui/Common/Select/StatelessSelect';
import StatelessSelect from '#ui/Common/Select/StatelessSelect';
const WithNoScriptSelect = <T extends string>({
as,
...props
}: StatelessSelectProps<T>) => {
const id = useId();
const selectId = `select-${id.replace(/[^a-zA-Z0-9]/g, '')}`;
return (
<>
<Select {...props} fallbackClass={selectId} />
<noscript>
<style>{`.${selectId} { display: none!important; }`}</style>
<StatelessSelect {...props} as={as} />
</noscript>
</>
);
};
export default WithNoScriptSelect;