sibi
sibi

Reputation: 675

React js in Aurelia js, call aurelia function

Am very new to react js and aurelia js, my requirement is use react for view and aurelia for model/routing and all. I refered this doc for installation, it works well.enter image description here Done like this,here my view is in react js, while clicking the details in the table(doted icons),needs to call a function which should be in aurelia. I followed the above mentioned doc for coding, instead of list in the my-react-element.jsx i changed into table style like in the pic.

Upvotes: 0

Views: 246

Answers (1)

sibi
sibi

Reputation: 675

Yeah, i got it. just understand passing value to components (custome-component in aurelia, component in react). In both, aurelia and react it works nearly same(like call-back function). Code : react-example.js Just declare a function, which you want to execute.

myfun(){
  alert('Hi, am in aurelia..');

}

react-example.html use bind to set the declared function to custome-component.

 <react-element myfun.bind = "myfun"></react-element>

react-example.js

@bindable('myfun')
<MyReactElement data={this.data} myfun={this.myfun}/>,

my-react-element.jsx

 <p onClick = {this.try.bind(this)} >click </p>

 try() {
   this.props.myfun(); }

Note : Basic knowledge of react and aurelia required and compare the doc to fix.

Upvotes: 1

Related Questions