javascript - react native router flux: override left or right button inside component and access local function -


i able override button inside compononent not able call local function, example when press "refresh", nothing happen. correct way override button text , perform function. appreciate. thanks.

import { webview } 'react-native' import react, { proptypes, component } 'react'; import { view, text } 'react-native';  import styles '../src/styles/home'  var webview_ref = 'webview'; class webviewcomponent extends component {    static righttitle = "refresh";   static onright() {     this.reload;   }    static proptypes = {     url: proptypes.string,     scalespagetofit: proptypes.bool,     startinloadingstate: proptypes.bool,   };    static defaultprops = {     url: 'http://google.com',     scalespagetofit: true,     startinloadingstate: true,   };    render() {     return (       <webview           ref={ webview_ref }           style={ { flex: 1, margintop: 50 } }           source={ { uri: this.props.url } }           scalespagetofit={ this.props.scalespagetofit }           startinloadingstate={ this.props.startinloadingstate } />       );   }    reload = () => {     alert('reload');   };  }  module.exports = webviewcomponent; 

i answer after research, dont use static, use componentdidmount()

import { webview } 'react-native' import react, { proptypes, component } 'react'; import { view, text } 'react-native';  import styles '../src/styles/home'  var webview_ref = 'webview'; class webviewcomponent extends component {    //here answer   componentdidmount() {     actions.refresh({righttitle: 'refresh', onright: this.reload})   }    static proptypes = {     url: proptypes.string,     scalespagetofit: proptypes.bool,     startinloadingstate: proptypes.bool,   };    static defaultprops = {     url: 'http://google.com',     scalespagetofit: true,     startinloadingstate: true,   };    render() {     return (       <webview           ref={ webview_ref }           style={ { flex: 1, margintop: 50 } }           source={ { uri: this.props.url } }           scalespagetofit={ this.props.scalespagetofit }           startinloadingstate={ this.props.startinloadingstate } />       );   }    reload = () => {     alert('reload');   };  }  module.exports = webviewcomponent; 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -