mercredi 1 septembre 2021

Conditional rendering in react prop

I want to ask if this possible in react while passing props or something similar. Eslint underlined the whole process in red.

Component A, 
enter code here
<div>
<button style=> Submit</button>
<button style=> Loading</button>
</div>


Component B
import ComponentA from 'A',

export default class ComponentB extends Component {
constructor(props) {
super();
this.state = {
     load:false,
    }

  handleSubmit = (e) => {
   e.preventDefault();
   this.setState({
    load:true,
  })
 }

 render () {
 return (
 <ComponentA  {this.state.load ? (props.loading): (props.submit)}/>
  )

 }

Aucun commentaire:

Enregistrer un commentaire