2015-01-14 37 views
7

Giriş etiketim var ve yer tutucu içeriğini içeriğin bileşenlerine ayarlamaya çalışıyorum. JSX'i derledikten ve tarayıcıda çalıştırdıktan sonra, yer tutucu hiç görünmez. Ayrıca herhangi bir hata atmıyor. Bunu nasıl yapabilirim?React JSX: Yer tutucu özniteliğine nasıl ayarlanır?

<input type="text" onChange={this.props.handleChange} placeholder={this.props.name} /> 
+2

jsbin - http://jsbin.com/yepufugige/4/edit – filipemgs

+0

Teşekkürler! Sahne eşyalarımı yanlış ayarlıyordum. – astone

cevap

4

Bu bileşende bu kodda yanlış bir şey yok gibi görünüyor. Yer tutucu, uygularken yaptığınız gibi iyi görünmelidir. İşte

Ben ebeveyn ayarladığınız nasıl:

İşte
import React, { Component } from 'react'; 
import Title from'./Title'; 
import TestList from'./TestList'; 

export default class Layout extends Component { 
    constructor() { 
     super(); 
     this.state = { 
      title: 'Moving Focus with arrow keys.', 
      placeholder:'Search for something...' 
     }; 
    } 

    render() {  
     return (
      <div > 
       <Title title={ this.state.title } /> 
       <p>{ this.getVal() }</p> 
       <TestList placeholderText={this.state.placeholder} /> 
      </div> 
     ); 
    } 
} 

olduğunu ben çocukta görüntülemek nasıl:

import React, { Component } from 'react'; 

export default class TestInput extends Component { 
    constructor(props){ 
     super(props); 
    }; 

    render() { 
     return (
      <div> 
       <input type="search" placeholder={this.props.placeholderText} /> 
      ); 
     } 
    } 
} 

bir geç cevap Biraz ama umut olur! :-)