Skip to content
This repository was archived by the owner on Mar 7, 2018. It is now read-only.

Include places in filter auto-suggest - #45

Merged
c-w merged 14 commits into
masterfrom
places-autosuggest
Sep 13, 2017
Merged

c-w merged 14 commits into
masterfrom
places-autosuggest

Conversation

@c-w

@c-w c-w commented Sep 13, 2017 •

Copy link
Copy Markdown
Contributor

Searching for locations

Switching search dataset

Searching for topics

Close-up of styling

@c-w
c-w force-pushed the places-autosuggest branch from 8480f51 to 9e6d342 Compare September 13, 2017 11:59

getHeatmapTiles(fromDate, toDate, zoomLevel, maintopic, tileid, periodType,
dataSource, externalsourceid, conjunctivetopics, callback) {
console.log(`processing tile request [${maintopic}, ${fromDate}, ${toDate}, ${tileid}}]`)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we leave this in for the moment as I depend on this for monitoring / debugging. this will be removed before we go live.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates a lot of noise and makes other debugging harder... but sure. 84969b0

suggestions={suggestions}
inputProps={inputProps}
focusInputOnSuggestionClick={true}
onSuggestionSelected={this.onSuggestionSelected}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree that this should be there but you forgot to bind onSuggestionSelected to the component in the constructor.

@c-w c-w Sep 13, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary given that the function now is an arrow function. You can learn more about how this works in this article (see "Approach 5: Arrow Function in Class Property").

It's much neater to use the arrow-function approach over the explicit bind approach (no duplicate code and potential to forget to bind the function) and it doesn't suffer from the performance overhead of re-declaring arrow function in the render method (this will cause a re-render of the component on every cycle since React has no way of knowing that the arrow function declared in render always is the same).

<div style={styles.searchBox}>
{ <TypeaheadSearch
dashboardRefreshFunc={(maintopic, conjunctivetopics)=>this.handleDataFetch(maintopic, conjunctivetopics)}
dashboardRefreshFunc={this.handleDataFetch}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bind handleDataFetch

@c-w c-w Sep 13, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary given that the function now is an arrow function. You can learn more about how this works in this article (see "Approach 5: Arrow Function in Class Property").

It's much neater to use the arrow-function approach over the explicit bind approach (no duplicate code and potential to forget to bind the function) and it doesn't suffer from the performance overhead of re-declaring arrow function in the render method (this will cause a re-render of the component on every cycle since React has no way of knowing that the arrow function declared in render always is the same).

'Term': 'fa fa-tag fa-2x',
};

function fetchLocationsFromFeatureService(bbox, matchName, callback) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this function under the services folder

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a fairly specific function so there won't be much potential for re-using it, but sure. 9fece04

@c-w

c-w commented Sep 13, 2017

Copy link
Copy Markdown
Contributor Author

@erikschlegel NB: the arrow functions for binding work even on very old npm :)

image

@c-w
c-w merged commit 75e14a4 into master Sep 13, 2017
@c-w
c-w deleted the places-autosuggest branch September 13, 2017 19:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants