-
Notifications
You must be signed in to change notification settings - Fork 93
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
Feature/map routing #3508
Feature/map routing #3508
Conversation
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.
very interesting approach! good job guys! 👏 👏
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.
You got something really good 🌎 👏 , and very glad to help a bit here!
@@ -1,74 +0,0 @@ | |||
export const initialState = { |
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.
👏
import { getMapSettings } from '../../map-selectors'; | ||
|
||
const mapStateToProps = ({ location }) => ({ | ||
settings: getMapSettings(location) |
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 sure this working perfectly, we have to take a look here https://github.com/reduxjs/reselect#sharing-selectors-with-props-across-multiple-component-instances to be 100% sure.
@@ -44,8 +50,8 @@ class MapContainer extends PureComponent { | |||
} | |||
|
|||
componentWillReceiveProps(nextProps) { |
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 will be deprecated soon, why don't use componentDidUpdate instead?
Loving the structure selector! Feel free to merge and thanks! |
Overview
This is a big one. Both in file changes and architecture, so please review with an open mind and with caution!
So the new map we are going to need to manage a large amount of state specific to many components on the page. Additionally this map needs to be able to exist in the map page, dashboards, and potentially other forms and pages. So how do we make sure we can manage the map state robustly, in isolation, and not have to faff around with lots of url and location functions every time we use the map. Simple! We use the same encoding method we have been using for the widgets, but with some updates:
?map=state
key in the url and bind it to the url by creating a singlesetMapSettings
action to dispatch to redux-first-router.querySerializer
of the routerquerySerializer
encoder to make sure what we are dealing with is an object and then encode it and send to the urllocation
key on the store is now holding the state of each component under a suitable key which can easily be passed to the component with its mapStateToProps and selectors.This approach removes the need to dispatch an additional action to sync the url with the store like before, improving performance, and reduces complexity in the router when wanting to include a new component in a page.
Disadvantage: unreadble urls.
NOTE: I have left in some commented functions incase this approach is not approved to that we can comprise on some features.
Demo
Open up redux tools, and try the zoom buttons on the map.
Credit: pretty much @j8seangel's PR.