From 04440c9e51aa9a0f7ee1c4cf6ba4b38234897dd1 Mon Sep 17 00:00:00 2001 From: rbokhorst <rbokhorst@astron.nl> Date: Fri, 2 Nov 2018 07:40:57 +0000 Subject: [PATCH] OSB-31: documentation --- .../src/components/StationAutoComplete.js | 7 +++++++ .../maintenancedb_view/src/pages/StationOverviewPage.js | 1 + 2 files changed, 8 insertions(+) diff --git a/LCU/Maintenance/MDB_WebView/maintenancedb_view/src/components/StationAutoComplete.js b/LCU/Maintenance/MDB_WebView/maintenancedb_view/src/components/StationAutoComplete.js index 4816c8f37cb..383544a188e 100644 --- a/LCU/Maintenance/MDB_WebView/maintenancedb_view/src/components/StationAutoComplete.js +++ b/LCU/Maintenance/MDB_WebView/maintenancedb_view/src/components/StationAutoComplete.js @@ -11,6 +11,13 @@ import './StationAutoComplete.css' * The parent component is notified about a new station name (through the onChange callback) * when the user presses 'Enter' in the input field or when an item from the list of * suggestions is chosen. + * + * When using this component, in most cases you want to add a key with the value of the current + * selected station. This forces a new instance instead of only a rerendering when the + * selected station was changed outside this component. In a new instance the state.value is + * set to the selectedStation prop. + * + * Usage: <StationAutoComplete key={station} selectedStation={station} onChange={onchange} /> */ class StationAutoCompleteC extends Component { diff --git a/LCU/Maintenance/MDB_WebView/maintenancedb_view/src/pages/StationOverviewPage.js b/LCU/Maintenance/MDB_WebView/maintenancedb_view/src/pages/StationOverviewPage.js index 02a52f8f3fd..1fbde34156e 100644 --- a/LCU/Maintenance/MDB_WebView/maintenancedb_view/src/pages/StationOverviewPage.js +++ b/LCU/Maintenance/MDB_WebView/maintenancedb_view/src/pages/StationOverviewPage.js @@ -84,6 +84,7 @@ class ToolBarC extends Component { } render() { + // The key on StationAutoComplete is important, see the desc of StationAutoComplete return (<div className="toolbar-top"> <StationAutoComplete key={this.props.selectedStation} selectedStation={this.props.selectedStation} onChange={this.onStationChange}/> -- GitLab