Sono nuovo di reagire e sto cercando di rendere un nuovo elemento onClick:Render nuovo elemento onClick in react.js
var LoginButton = React.createClass({
..............
..............
clickHandle : function() {
this.rememberMe = {
active: localforage.getItem('rememberMe', function (err, key) {
return key;
})
};
if (this.rememberMe.active == true || this.rememberMe.active == 'checked')
{
document.getElementById('loginForm').submit();
}
else {
React.render(<wantToRemember />, document.getElementById('loginbuttonhere'));
}
return this.rememberMe.active;
},
Questo è l'elemento che deve apparire:
var wantToRemember = React.createClass({
getInitialState : function() {
return {
position: 'absolute',
display: 'block',
top: '20px',
width: '100px',
height: '100px'
}
},
render : function() {
return (
<div className="rememberPopup" style={this.state}>
<div className="row">
<div className="staylogin">
<div className="col-md-4">
<label for="checkbox">Angemeldet bleiben</label>
</div>
<div className="col-md-1">
<input type="checkbox" id="checkbox" name="remember" />
</div>
</div>
</div>
</div>
);
}
});
ma non sembra, invece reagire rende questo html:
<wanttoremember data-reactid=".1"></wanttoremember>
sono abbastanza sicuro che sto facendo alcune cose piuttosto semplice sbagliato, ma non riesce a capire wh a. Non è possibile chiamare elementi diversi come questo?
Grazie! Questo era – baao
Questa risposta è in realtà un comportamento e pattern JSX più corretto: http://stackoverflow.com/a/29799455/95190 – WiredPrairie