Props with Stateless Functional Components

Tell us what’s happening:

Your code so far


class CampSite extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <div>
        <Camper name="CamperBot"/>
      </div>
    );
  }
};
// change code below this line
const Camper=(props)=>{
return(
<div>
<p>{name.props}</p>
</div>
)
}
Camper.defaultProps="CamperBot"
Camper.propTypes={name:PropTypes.string.isRequired}

Maybe props.name instead of name.props?

thanks got it. can you please help me with this.

class ControlledInput extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      input: ''
    };
    // change code below this line
this.handleChange = this.handleChange.bind(this)
    // change code above this line
  }
  // change code below this line
handleChange(event){
this.setState({
  input:event.input.value
});
}
  // change code above this line
  render() {
    return (
      <div>
        { /* change code below this line */}
<input value = {this.state.input} onChange = {this.handleChange.bind(this)}/>
        { /* change code above this line */}
        <h4>Controlled Input:</h4>
        <p>{this.state.input}</p>
      </div>
    );
  }
};

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums