Có vẻ như không có gì sai với mã này trong thành phần con. Trình giữ chỗ sẽ hiển thị tốt, khi bạn triển khai nó.
Dưới đây là làm thế nào tôi có nó thiết lập trong các phụ huynh:
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>
);
}
}
Dưới đây là cách tôi hiển thị nó trong con:
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} />
);
}
}
}
Bit của bài trả lời muộn nhưng hy vọng nó sẽ giúp! :-)
jsbin - http://jsbin.com/yepufugige/4/edit – filipemgs
cảm ơn bạn! Tôi đã thiết lập các đạo cụ của tôi không chính xác. – astone