Created
February 5, 2019 18:12
-
-
Save dovidweisz/7d065cbeb3eec2424bdd5110fddde5b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class TranslationWidget extends Component { | |
constructor(props, c) { | |
super(props, c); | |
this.state = { | |
items: this.props.value | |
}; | |
} | |
onChange(key, value) { | |
this.setState({ | |
items: { | |
[key]: value | |
} | |
}); | |
} | |
render() { | |
return ( | |
<div> | |
{Object.entries(this.state.items).map(([key, value], i) => ( | |
<div key={key}> | |
<label for={labelr(key)}>{key}</label> | |
<input | |
type="text" | |
name={labelr(key)} | |
value={value} | |
onChange={event => this.onChange(key, event.target.value)} | |
/> | |
</div> | |
))} | |
<button onClick={() => this.props.onChange(this.state.items)}> | |
Save Changes | |
</button> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment