I'm new to React and have several cards that, when clicked, should open a modal however I don't know what to write in <Modal trigger={}>
in my Modal component in order to get the Cards from the Card component.
How would I link the modal to each card so that onClick of the card, the modal appears?
Home.js
class Home extends React.Component {
constructor(props) {
super(props)
this.state = { isEmptyState: true }
}
triggerOpenAlertState = () => {
this.setState({
...this.state,
isEmptyState: false,
isOpenAlertState: true
})
}
render() {
return (
<div>
<i class="star outline icon big" id="favourites"></i>
<GoogleAuth />
<div>
{this.state.isEmptyState && <Cards openAlert={this.triggerOpenAlertState} />}
{this.state.isOpenAlertState && <ModalExample />}
</div>
</div>
)
}
}
Modal.js
const ModalExample = () => (
<Modal trigger={}>
<Modal.Header>Sign In</Modal.Header>
<Modal.Content>
<p>
You must Sign In before you can add project ideas to your favourites.
</p>
</Modal.Content>
</Modal>
)
export default ModalExample
Cards.js
const Cards = props => {
return (
<div class="row">
<div class="column"><div onClick={props.openAlert} class="header card">Communication app for tenants/landlords</div></div>
<div class="column"><div onClick={props.openAlert} class="header card">Code Snippet Manager</div></div>
<div class="column"><div onClick={props.openAlert} class="header card">Reservation Management System</div></div>
<div class="column"> <div onClick={props.openAlert} class="header card">Budget Tracker</div></div>
<div class="column"><div onClick={props.openAlert} class="header card">Caesar Cipher</div></div>
<div class="column"><div onClick={props.openAlert} class="header card">Tax Calculator</div></div>
<div class="column"><div onClick={props.openAlert} class="header card">Meme Generator</div></div>
<div class="column"><div onClick={props.openAlert} class="header card">Virtual Interior Design app</div></div>
<div class="column"><div onClick={props.openAlert} class="header card">App for the Elderly</div></div>
</div>