cara lulus fungsi sebagai alat peraga dalam reaksi js
import React from 'react';
import './App.css';
import NewComponent from './components/NewComponent';
// import NewFunctionalComponent from './components/NewFunctionalComponent';
class App extends React.Component {
constructor(){
super()
this.state = {
isClicked: false
}
console.log(this.state)
}
handleClick = () => {
console.log('I have been clicked')
this.setState({
isClicked: true
}, () => console.log(this.state.isClicked))
}
render() {
return (
<div className="App">
<NewComponent clickMe={this.handleClick} />
{/* <NewFunctionalComponent noClickMe={this.handleClick} /> */}
</div>
)
}
}
export default App;
Expensive Eland