Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
additional info
Source Link
runnerpaul
  • 7.6k
  • 10
  • 73
  • 165

I have this span:

<span className="close" onClick={this.props.handleClose}><u>Close</u> X</span> 

handleClose sets a property which is used to either show or hide a popup. I want to edit this onClick to also call a rest endpoint if updateDocsFlag is set to true by this function:

doIsChecked() { var isItChecked = document.getElementById('isPless') as HTMLInputElement; if (isItChecked.checked) { this.setState({ updateDocsFlag: true }); } else { this.setState({ updateDocsFlag: false }); } } 

Can that be done? If so I assume if it can it'll be something like creating a function to make the rest call and including it in the onClick but I'm not sure if multiple functions can be called in this way.

handleClose comes from a different class. This is what it looks like:

<Pless handleClose={this.hidePless} showPless={this.state.showPlessPrompt} /> hidePless = () => { this.setState({ showPlessPrompt: false }); }; 

In my Pless class I have this interface:

interface Props { handleClose: () => void; showPless: boolean; } 

I have this span:

<span className="close" onClick={this.props.handleClose}><u>Close</u> X</span> 

handleClose sets a property which is used to either show or hide a popup. I want to edit this onClick to also call a rest endpoint if updateDocsFlag is set to true by this function:

doIsChecked() { var isItChecked = document.getElementById('isPless') as HTMLInputElement; if (isItChecked.checked) { this.setState({ updateDocsFlag: true }); } else { this.setState({ updateDocsFlag: false }); } } 

Can that be done? If so I assume if it can it'll be something like creating a function to make the rest call and including it in the onClick but I'm not sure if multiple functions can be called in this way.

I have this span:

<span className="close" onClick={this.props.handleClose}><u>Close</u> X</span> 

handleClose sets a property which is used to either show or hide a popup. I want to edit this onClick to also call a rest endpoint if updateDocsFlag is set to true by this function:

doIsChecked() { var isItChecked = document.getElementById('isPless') as HTMLInputElement; if (isItChecked.checked) { this.setState({ updateDocsFlag: true }); } else { this.setState({ updateDocsFlag: false }); } } 

Can that be done? If so I assume if it can it'll be something like creating a function to make the rest call and including it in the onClick but I'm not sure if multiple functions can be called in this way.

handleClose comes from a different class. This is what it looks like:

<Pless handleClose={this.hidePless} showPless={this.state.showPlessPrompt} /> hidePless = () => { this.setState({ showPlessPrompt: false }); }; 

In my Pless class I have this interface:

interface Props { handleClose: () => void; showPless: boolean; } 
Source Link
runnerpaul
  • 7.6k
  • 10
  • 73
  • 165

call multiple functions in onClick

I have this span:

<span className="close" onClick={this.props.handleClose}><u>Close</u> X</span> 

handleClose sets a property which is used to either show or hide a popup. I want to edit this onClick to also call a rest endpoint if updateDocsFlag is set to true by this function:

doIsChecked() { var isItChecked = document.getElementById('isPless') as HTMLInputElement; if (isItChecked.checked) { this.setState({ updateDocsFlag: true }); } else { this.setState({ updateDocsFlag: false }); } } 

Can that be done? If so I assume if it can it'll be something like creating a function to make the rest call and including it in the onClick but I'm not sure if multiple functions can be called in this way.