Merge pull request #3164 from matrix-org/t3chguy/fix_proptypes_mismatches

Fix some React errors
This commit is contained in:
Michael Telatynski 2019-07-09 10:59:29 +01:00 committed by GitHub
commit 349afb13f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 7 deletions

View file

@ -88,6 +88,7 @@ export class EditableItem extends React.Component {
export default class EditableItemList extends React.Component { export default class EditableItemList extends React.Component {
static propTypes = { static propTypes = {
id: PropTypes.string.isRequired,
items: PropTypes.arrayOf(PropTypes.string).isRequired, items: PropTypes.arrayOf(PropTypes.string).isRequired,
itemsLabel: PropTypes.string, itemsLabel: PropTypes.string,
noItemsLabel: PropTypes.string, noItemsLabel: PropTypes.string,
@ -121,10 +122,8 @@ export default class EditableItemList extends React.Component {
return ( return (
<form onSubmit={this._onItemAdded} autoComplete={false} <form onSubmit={this._onItemAdded} autoComplete={false}
noValidate={true} className="mx_EditableItemList_newItem"> noValidate={true} className="mx_EditableItemList_newItem">
<Field id="newEmailAddress" label={this.props.placeholder} <Field id={`mx_EditableItemList_new_${this.props.id}`} label={this.props.placeholder} type="text"
type="text" autoComplete="off" value={this.props.newItem} autoComplete="off" value={this.props.newItem || ""} onChange={this._onNewItemChanged} />
onChange={this._onNewItemChanged}
/>
<AccessibleButton onClick={this._onItemAdded} kind="primary"> <AccessibleButton onClick={this._onItemAdded} kind="primary">
{_t("Add")} {_t("Add")}
</AccessibleButton> </AccessibleButton>
@ -135,11 +134,11 @@ export default class EditableItemList extends React.Component {
render() { render() {
const editableItems = this.props.items.map((item, index) => { const editableItems = this.props.items.map((item, index) => {
if (!this.props.canRemove) { if (!this.props.canRemove) {
return <li>{item}</li>; return <li key={item}>{item}</li>;
} }
return <EditableItem return <EditableItem
key={index} key={item}
index={index} index={index}
value={item} value={item}
onRemove={this._onItemRemoved} onRemove={this._onItemRemoved}

View file

@ -234,6 +234,7 @@ export default class AliasSettings extends React.Component {
<div className='mx_AliasSettings'> <div className='mx_AliasSettings'>
{canonicalAliasSection} {canonicalAliasSection}
<EditableItemList <EditableItemList
id="roomAliases"
className={"mx_RoomSettings_localAliases"} className={"mx_RoomSettings_localAliases"}
items={this.state.domainToAliases[localDomain] || []} items={this.state.domainToAliases[localDomain] || []}
newItem={this.state.newAlias} newItem={this.state.newAlias}

View file

@ -103,6 +103,7 @@ export default class RelatedGroupSettings extends React.Component {
const EditableItemList = sdk.getComponent('elements.EditableItemList'); const EditableItemList = sdk.getComponent('elements.EditableItemList');
return <div> return <div>
<EditableItemList <EditableItemList
id="relatedGroups"
items={this.state.newGroupsList} items={this.state.newGroupsList}
className={"mx_RelatedGroupSettings"} className={"mx_RelatedGroupSettings"}
newItem={this.state.newGroupId} newItem={this.state.newGroupId}

View file

@ -139,7 +139,7 @@ export default class PreferencesUserSettingsTab extends React.Component {
{minimizeToTrayOption} {minimizeToTrayOption}
{autoLaunchOption} {autoLaunchOption}
<Field id={"autocompleteDelay"} label={_t('Autocomplete delay (ms)')} type='number' <Field id={"autocompleteDelay"} label={_t('Autocomplete delay (ms)')} type='number'
value={SettingsStore.getValueAt(SettingLevel.DEVICE, 'autocompleteDelay')} value={SettingsStore.getValueAt(SettingLevel.DEVICE, 'autocompleteDelay').toString(10)}
onChange={this._onAutocompleteDelayChange} /> onChange={this._onAutocompleteDelayChange} />
</div> </div>
</div> </div>