-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validation type functionality #153
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
package-lock.json
Outdated
@@ -0,0 +1,6 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: This file can be deleted.
|
||
const fetcher = (url: string) => fetch(url).then((res) => res.json()); | ||
|
||
preload(`https://www.otelbin.io/validation/supported-distributions`, fetcher); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: This can now be removed as we are preloading the distros using an instruction in the root layout (has better performance characteristics).
version: "", | ||
distro: "", | ||
const [{ distro, distroVersion }] = useUrlState([distroBinding, distroVersionBinding]); | ||
const [currentDistro, setCurrentDistro] = useState<ICurrentValidation>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Why do we need this state?
I would expect that the combination of URL state and the result of useDistributions
is sufficient to generate the right label. This would also avoid the need for useMemo
and useEffect
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly today I tried the approach without useState, but at final step, without useState and useEffect, for the first state change, useUrlState couldn't change the whole state of the app, (ex: display current flag, or button title). If you're sure useUrlState is enough, I'll try again. @bripkens
current: ICurrentValidation; | ||
setCurrent: (current: ICurrentValidation) => void; | ||
currentDistro: ICurrentValidation; | ||
setCurrentDistro: (current: ICurrentValidation) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Why do we need setCurrentDistro
here? We already have getUrl
accessible within the file that we can use to change the distro.
<Button | ||
onClick={() => setCurrent({ provider: "Browser-only", version: "", distro: "" })} | ||
onClick={() => { | ||
setCurrentDistro({ ...currentDistro, title: { provider: "Browser-only", version: "", distro: "" } }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: There should only be one source of truth for state, i.e. the URL.
version: (data && Array.isArray(data[key]?.releases) && data[key]?.releases[0]?.version) || "", | ||
})) | ||
: []; | ||
const [{}, getUrl] = useUrlState([distroBinding, distroVersionBinding]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
No description provided.