import { useContext, useEffect, useState } from 'react';
const Log = () => {
useEffect(() => {
console.log('Running ...')
},[])
return(<p>here</p>)
}
export default Log;
Run Code Online (Sandbox Code Playgroud)
每当此代码运行时,我都会 在浏览器控制台中收到两次正在运行...消息。
我认为它应该运行一次,因为我在 useEffect 中有一个空的第二个参数。
谁能解释一下为什么它运行两次?
我是本机反应的新手,我正在使用react-navigation和react-navigation-material-bottom-tabs。
我想要做的就是弯曲底部标签栏的右上角和左上角。
我的代码:
const screen1 = createMaterialBottomTabNavigator(
{
Home: {
screen: HomeScreen,
style : {
backgroundColor: 'black'
}
},
About: AboutScreen,
Scan: ScanScreen,
Fav: AllScreen
},
{
initialRouteName: "Home",
activeColor: 'red',
inactiveColor: 'blue',
barStyle: {
borderWidth: 0.5,
borderBottomWidth: 1,
backgroundColor: 'white',
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
borderTopLeftRadius: 15,
borderTopRightRadius: 15,
borderTopColor: '#000',
borderBottomColor: '#000',
borderLeftColor: '#000',
borderRightColor: '#000',
},
}
);
Run Code Online (Sandbox Code Playgroud)