我正在尝试将sqrtoccurrence(2, 10) // 1
sqrtoccurrence(2, 100) // 2
sqrtoccurrence(2, 1000) // 3
sqrtoccurrence(2, 1000000) // 4
sqrtoccurrence(2, Int.MaxValue) // 4
def log2(x: Double): Double = math.log(x) / math.log(2)
log2(log2(10)) // 1.732
log2(log2(100)) // 2.732
log2(log2(1000)) // 3.317
log2(log2(1000000)) // 4.317
log2(log2(Int.MaxValue)) // 4.954
设置为初始状态,但是我不确定。当我将数据发送到full_name
时,我无法检查这一点,如何在数据加载完成后才能设置此初始状态。
props.userDetailsFetchRequest(id, data);
佐贺
const UserDetails = props => {
const classes = useStyles();
const { userDetailsLoading } = props;
const { full_name } = props.userDetails;
console.log('loading:', userDetailsLoading)
console.log('full name:', full_name)
const [name, setName] = useState(full name); <-------- I want this inicialize with
michele sena riveira
function handleSubmit(e) {
e.preventDefault();
const { id } = props.userDetails;
const data = {
"full_name": name,
}
props.userDetailsFetchRequest(id, data); <--- I'm sending this request to my saga
and I'm getting full_name as undefined.
}
答案 0 :(得分:2)
您将为此使用useEffect
useEffect(() => {
setName(full_name)
},[full_name]
现在,每当full_name更改时,效果将使用道具的值更新您的状态值。
不过,最好在可能的时候直接使用道具,以消除任何可能的差异