Skip to content

Commit

Permalink
Pass unique id to select-react
Browse files Browse the repository at this point in the history
Suppress: 'Props id did not match' errors
  • Loading branch information
nonylene committed Feb 12, 2024
1 parent fdcdc2b commit 3661672
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion app/components/search-box/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { LinksFunction } from "@remix-run/node";
import { Form, Link, useSubmit } from "@remix-run/react";
import { useEffect, useRef, useState } from "react";
import { useEffect, useId, useRef, useState } from "react";
import Select from "react-select";

export const links: LinksFunction = () => [{ rel: "stylesheet", href: styles }];
Expand Down Expand Up @@ -101,6 +101,12 @@ export function SearchBox(props: SearchBoxProps) {
</div>
<div className="col-auto mt-3 ms-auto me-md-1 text-end ps-0">
<Select
instanceId={
// https://github.com/JedWatson/react-select/issues/5459
// https://stackoverflow.com/a/73117797/4205654
// Still has an issue: https://github.com/JedWatson/react-select/issues/3590
useId()
}
options={props.types}
isMulti={true}
isClearable={false}
Expand Down
8 changes: 7 additions & 1 deletion app/components/sort-button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useState } from "react";
import { useEffect, useId, useState } from "react";
import Select from "react-select";

interface SortOrderOption {
Expand Down Expand Up @@ -32,6 +32,12 @@ export default function SortButton(props: SortButtonProps) {
<>
<div className="col-auto ms-auto text-end ps-0">
<Select
instanceId={
// https://github.com/JedWatson/react-select/issues/5459
// https://stackoverflow.com/a/73117797/4205654
// Still has an issue: https://github.com/JedWatson/react-select/issues/3590
useId()
}
options={props.options}
value={getOrderOption(props.options, order)}
onChange={(e) => {
Expand Down

0 comments on commit 3661672

Please sign in to comment.