title: How can I pass a function to a header button in react navigation's navigationOptions?
body: <p><strong>What I want to do:</strong></p>
  
  <p>I have a screen with an add button on the header.
  When I click it a modal opens and it should pass in a function into this opened modal.</p>
  
  <p>But I can't make it work because I don't use classes. </p>
  
  <p>This is how I do it:</p>
  
  <pre><code>PlayerScreen.navigationOptions = ({ navigation, screenProps }) =&gt; {
    console.log("screen props", screenProps);
    return {
      title: "Spieler",
      headerRight: (
        &lt;Button
          onPress={() =&gt; navigation.navigate("AddPlayerModal", {addPlayer})}
          title="+"
          color="black"
        /&gt;
      )
    };
  };
  </code></pre>
  
  <p>The problem is <code>addPlayer</code> is a function from the PlayerScreen Component. So I have no way to access it like this. 
  Is there a way to pass the function in somehow? I think I could use a class and then I should have access in the static <code>navigationOptions</code> method right? </p>
  
  <p>But I want to make it work without creating a class.
  So is there a way?</p>
  
  <p><strong>What have I tried:</strong></p>
  
  <p>I tried to set the param like this on the <code>PlayerScreen</code> component:</p>
  
  <pre><code>useEffect(() =&gt; {
      navigation.setParams({ addPlayer });
    }, []);
  </code></pre>
  
  <p>But in the modal when I do this:</p>
  
  <p><code>const addPlayer = navigation.getParam("addPlayer");</code></p>
  
  <p><code>addPlayer</code> is undefined.</p>
  
  <p>Thank you in advance, Geralt</p>