Advertisement
DeepCode00

Untitled

Dec 31st, 2018
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //stato iniziale dello store
  2. const initialState = {
  3.     pgCurrent: "",
  4.     pg: {
  5.         "Franco Nero": {
  6.             nome: "Fraco",
  7.             cognome: "Nero",
  8.             origine: "Italia",
  9.             descrizione_fisica: "descrizone",
  10.             background: "sua storia"
  11.         },
  12.         "Enzo Biagi": {
  13.             nome: "Enzo",
  14.             cognome: "Biagi",
  15.             origine: "Italia",
  16.             descrizione_fisica: "Bianco",
  17.             background: "Molto"
  18.         }    
  19.     },
  20.     pgAction: "",
  21. }
  22. //componente
  23. import React, {Component} from 'react';
  24.  
  25. class PgCard extends Component {
  26.     Pg = {};
  27.     onClickPgEdit = () => {
  28.         this.props.onClickPgEdit("edit");
  29.     }
  30.     hChange = (Pg,e) => {
  31.         this.Pg['origine']=e.target.value;
  32.         console.log(this.Pg['origine'])
  33.     }
  34.     render() {
  35.         [...]
  36.                 return (
  37.                     <div className="card">
  38.                         <div className="card-header">
  39.                             Modifica personaggio -
  40.                         </div>
  41.                         <div className="card-body">
  42.                             <h5 className="card-title">{this.props.name}</h5>
  43.                             <form>
  44.                                 {Object.keys(this.Pg).map(k => {
  45.                                     return (<div className="form-group" key={`form-group-${k}`}>
  46.                                         <label style={{textTransform: 'capitalize'}} key={`label-${k}`}>{k}</label>
  47.                                         <input onChange={(value) => this.hChange(this.Pg,value)} type="text" className="form-control" key={`input-${k}`} value={this.Pg[k]} />
  48.                                     </div>)
  49.                                 })}
  50.                                 <button onClick={this.onClickSubmit}>Save</button>
  51.                             </form>
  52.                         </div>
  53.                     </div>
  54.                 )
  55.             }    
  56.         }
  57.     }
  58. }
  59.  
  60. export default PgCard;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement