-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add feature to show popup for request in URL param #71
Conversation
const [popup, setPopup] = useState(); | ||
|
||
// display popup if request code is present in URL search param | ||
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.
have to wrap this with useEffect so it only fires once the layers have been mounted.
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.
why do we need useEffect? don't we have all the info on render if paramRequest is truthy?
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'm not 100% sure on the details of this but if you remove the useEffect wrapper, React just tries to rerender the component over and over again, resulting in Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.
I think it's because we are updating the state during render, versus after render if we useEffect. EIther way when working with maps, I have found it to be best to let layers render first before imposing state on it to prevent an unexpected sequence of events.
"bottom-left": [12, -38], | ||
bottom: [0, -38], | ||
"bottom-right": [-12, -38] | ||
"bottom-left": [6, -19], |
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.
just fixing offset so popover is closer to the marker.
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.
Thanks for the PR! Sorry for the delay. Only one comment.
const [popup, setPopup] = useState(); | ||
|
||
// display popup if request code is present in URL search param | ||
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.
why do we need useEffect? don't we have all the info on render if paramRequest is truthy?
4375200
to
5d6a1dd
Compare
Summary
Allow /delivery-needed to receive a request code via URL param and to display popover for corresponding request (if it exists).
e.g. http://localhost:3000/delivery-needed?request=MD4VL2 will open the app with the popover for
MD4VL2
open.If the request cannot be found, it will display a warning alert with a link to return to the default view. This is to hopefully prevent confusion for folks looking at the map for a claimed delivery/
![Screen Shot 2020-05-15 at 5 36 08 PM](https://user-images.githubusercontent.com/1868400/82098536-21597c80-96d3-11ea-879a-cbdc19bbd979.png)
This can be used for linking the request on the map in the Slack app, making it easier for delivery volunteers to look locations up on the map.
Limitations