我想調用function good
而不從事件中調用它。它應該在頁面打開後立即運行,就像在self invoking javascript function
中一樣。 Here is an example反應js中的自我調用函數? (如正常的javascript)
import React from 'react';
class App extends React.Component {
good(){
console.log('I was triggered during good')
}
render() {
console.log('I was triggered during render')
return(
<div>
good();
</div>
);
}
}
export default App;
很好解釋... :) – VivekN
真的有幫助 –