-
-
Notifications
You must be signed in to change notification settings - Fork 126
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
Make playground maps shareable by persisting data to the URL #18
Make playground maps shareable by persisting data to the URL #18
Conversation
docs/content/examples/map-editor.tsx
Outdated
const toMapObject = (data: string | null): MapObject | null => { | ||
if (!data) { | ||
return null; | ||
} | ||
|
||
try { | ||
return JSON.parse(data); | ||
} catch { | ||
return null; | ||
} | ||
}; |
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.
I feel like we should actually parse and validate each field here to match the shape of MapObject
, otherwise if data input is wrong it will fail later in the code and is confusing.
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.
Do you have a preferred strategy for the validation? We could introduce something like zod
or just add some lightweight validation for each field checking if it's present and if not, returning a default/empty value. I'd lean towards the latter in this case.
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.
This is looking great. I'm sorry for the slow review as I'm at a conference right now.
I added a few comments with minor modifications, do you mind doing an update?
@cpojer No rush, and yes, I can definitely update it! All good feedback |
0c876cf
to
d89db7d
Compare
Thanks for the contribution, this is great! |
…ch#18) Co-authored-by: cpojer <[email protected]>
Co-authored-by: Connor Lindsey <[email protected]> GitOrigin-RevId: 80499df94c87243652a05c36fa5c43bd079fae6b
Description
Resolves #13
Todo
id
andslug