Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //stato iniziale dello store
- const initialState = {
- pgCurrent: "",
- pg: {
- "Franco Nero": {
- nome: "Fraco",
- cognome: "Nero",
- origine: "Italia",
- descrizione_fisica: "descrizone",
- background: "sua storia"
- },
- "Enzo Biagi": {
- nome: "Enzo",
- cognome: "Biagi",
- origine: "Italia",
- descrizione_fisica: "Bianco",
- background: "Molto"
- }
- },
- pgAction: "",
- }
- //componente
- import React, {Component} from 'react';
- class PgCard extends Component {
- Pg = {};
- onClickPgEdit = () => {
- this.props.onClickPgEdit("edit");
- }
- hChange = (Pg,e) => {
- this.Pg['origine']=e.target.value;
- console.log(this.Pg['origine'])
- }
- render() {
- [...]
- return (
- <div className="card">
- <div className="card-header">
- Modifica personaggio -
- </div>
- <div className="card-body">
- <h5 className="card-title">{this.props.name}</h5>
- <form>
- {Object.keys(this.Pg).map(k => {
- return (<div className="form-group" key={`form-group-${k}`}>
- <label style={{textTransform: 'capitalize'}} key={`label-${k}`}>{k}</label>
- <input onChange={(value) => this.hChange(this.Pg,value)} type="text" className="form-control" key={`input-${k}`} value={this.Pg[k]} />
- </div>)
- })}
- <button onClick={this.onClickSubmit}>Save</button>
- </form>
- </div>
- </div>
- )
- }
- }
- }
- }
- export default PgCard;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement