title: How to use useLayoutEffect in Class component
body: <p>The documentation here <a href="https://reactnavigation.org/docs/header-buttons" rel="nofollow noreferrer">https://reactnavigation.org/docs/header-buttons</a> says I need to use useLayoutEffect to trigger a function from another file but I am using a class component and have no plan to switch to that other type.</p>
  <p>How do I re write this file so I can get access to <strong>navigation.getParam</strong> because now it's undefined</p>
  <pre><code>export default class Dashboard extends React.Component {
      constructor() {
        super();
        this.state = {
        };
      }
    
      onLogout = () =&gt; { 
        alert.alert('Alert', 'Testing...')
      }
    
      componentDidUpdate(){
        this.props.navigation.setParams({ onLogout: this.onLogout});
      }
      
      componentDidMount() {
        this.props.navigation.setParams({ onLogout: this.onLogout});
      }
    
    
      render() {
        return (
          &lt;View style={styles.container} /&gt;
        );
      }
    }
  </code></pre>
  <p>Navigation code</p>
  <pre><code>  &lt;BottomTab.Screen
      name=&quot;Dashboard&quot;
      component={Dashboard}
  
      options={({ route, navigation }) =&gt; ({
        // title: &quot;Dashboard&quot;,
        tabBarIcon: () =&gt; &lt;Icon name=&quot;printer&quot; size={20} color=&quot;black&quot; /&gt;,
        headerLeft: () =&gt; (
          &lt;Icon style={{ marginLeft: 14 }} name=&quot;user&quot; size={20} color=&quot;black&quot; /&gt;
        ),
        headerRight: (
          &lt;Button
          onPress={navigation.getParam('onLogout')}
        /&gt;
        )
      })}
    /&gt;
  </code></pre>