skydread1/flybot.sg

Blog sorting menu displays wrong option

Closed this issue · 0 comments

Problem

On the blog page, regardless of the user's chosen sorting option, the menu always shows the default ("Date created (newest first)").

This is probably caused by the value property of the select menu.

Suggestion

Replace the value property with defaultValue.

This is specific to React. Both value and defaultValue are valid, but in different situations—value should be used for "controlled" select boxes, while defaultValue should be used for "uncontrolled" select boxes.1

Footnotes

  1. https://react.dev/reference/react-dom/components/select