"dialog.showOpenDialog" Problem in Renderer Process


#1

use “dialog.showOpenDialog” in Renderer Process ( electron+reactjs ) system: osx 10.11.1

const React = require('react');
const ReactDOM = require('react-dom');
const remote = require('electron').remote;
const dialog = remote.require('electron').dialog;
const fs = require('fs');	
const md5 = require('md5');
var PathComponent = React.createClass({
	chooseFiles:function(){
		dialog.showOpenDialog({ 
		     filters: [{ name: 'Text', extensions: ['txt', 'js', 'md']}],
		     properties: [ 'openFile', 'openDirectory']
		   },
		     function (fileNames) {
		        if (fileNames === undefined) return;
		        var fileName = fileNames[0];

		        fs.readFile(fileName,function (err, stats) {
		            console.log(md5(stats));
		        });
		    }
		)

	},
	testFiles:function(){
		console.log("testFiles");
	},
	linkClick:function(){
		console.log("linkClick");
	},
	render:function(){
		return(
			<div>

				    	<button  onClick={this.chooseFiles}>chooseFiles</button>
				    	<br/>
						<button onClick={this.testFiles}>test</button>
						<br/>
						<a onClick={this.linkClick}>test</a>
			</div>
 		)
	}
});
ReactDOM.render(<PathComponent />, document.getElementById("example"));

After click <button onClick={this.chooseFiles}>chooseFiles</button> , it’s allway trigger “dialog.showOpenDialog” by other onClick actiion : <button onClick={this.testFiles}>test</button>,<a onClick={this.linkClick}>test</a>;

can anyone fix this problem?

code package zip