我使用了React-Bootstrap Modal,不明白爲什麼Foo組件渲染兩次?React-Bootstrap模態問題?
import { Modal, Button } from 'react-bootstrap';
const Foo = (props) => {
console.log(‘a’);
return(
<div>foo</div>
)
}
class Example extends Component {
render() {
return(
<Modal show={true}>
<Foo />
</Modal>
)
}
}
你是什麼意思執行兩次? –
你確定嗎?您是否嘗試重建或重新運行熱重新加載?看看代碼,這不能被渲染兩次。 – Fawaz