08-20-2021, 05:27 PM
(This post was last modified: 08-20-2021, 05:30 PM by remkonoteboom.)
Here is my full widget_config entry. Note that the view name is test/react/example01
Code:
<config>
<test.react.example01>
<mako>
<![CDATA[
from pyasm.search import Search
from pyasm.security import Site
from pyasm.biz import Project
search = Search("workflow/asset")
assets = search.get_sobjects()
assets_dict = []
for asset in assets:
asset_dict = asset.get_sobject_dict();
assets_dict.append(asset_dict)
kwargs['assets'] = assets_dict
]]>
</mako>
<html>
<div class="react_container" style="margin: 20px"/>
</html>
<jsx class="react_container" event="load"><![CDATA[
class LikeButton extends React.Component {
constructor(props) {
super(props);
this.state = { liked: false };
}
button_press = () => {
this.setState( {liked: true} )
}
render() {
if (this.state.liked) {
return 'You liked this.';
}
return (
<div class="button" onClick={ () => {this.button_press() } }
className="btn btn-primary">Like</div>
);
}
}
ReactDOM.render(React.createElement(LikeButton), bvr.src_el);
]]></jsx>
<behavior class="react_container" event="load"><![CDATA[
"use strict";
class LikeButton extends React.Component {
constructor(props) {
super(props);
this.state = {
liked: false
};
}
button_press = () => {
this.setState({
liked: true
});
};
render() {
if (this.state.liked) {
return 'You liked this.';
}
return React.createElement("div", {
class: "button",
onClick: () => {
this.button_press();
},
className: "btn btn-primary"
}, "Like");
}
}
ReactDOM.render(React.createElement(LikeButton), bvr.src_el);
]]></behavior>
</test.react.example01>
</config>