当我在一个modalOpen函数中使用onClick时,它不会在第一次单击时获取api,导致代码中断,但在第二次单击时,它会获取可能导致它的内容。
// get anime result and push to modal function
const modalAnime = async () => {
const { data } = await fetch(`${base_url}/anime/${animeId}`)
.then((data) => data.json())
.catch((err) => console.log(err));
如何让按钮在第一次单击时处于“按下”状态,在第二次单击时处于“正常”状态?你会用DirectButton或DirectCheckButton做这个吗?这就是我到目前为止所尝试的。 from direct.showbase.ShowBase import ShowBase
from direct.gui.DirectGui import *
class Core(ShowBase):
def __init__(self):
ShowBase.__init__(self)
ButtonBar()
class ButtonBar():
def
我正在尝试创建一个按钮来触发菜单的打开。我最初的想法是在按钮单击上设置状态,但是正在发生的情况是,第一次单击对状态或类没有任何影响。更改是在第二次单击和后续单击时触发的。
我理解为什么可见性的状态不能工作(因为setState是一种异步方法),但是如何使它从最初的单击中改变呢?
import React, { Component } from 'react';
export default class Social extends Component {
constructor() {
super();
// class of the div that
在下面的代码中,当我第一次单击按钮时,即使使用setState()更改了状态,它也会打印原始状态值。但当我第二次单击该按钮时,它会打印出新的状态值
import React, {Component} from 'react';
class App extends Component{
state = {
name:'Aneesh',
age: '30'
}
handleClick= (event)=>{
//this prints the original state
console.log(