Created
June 19, 2018 16:45
-
-
Save udaragangabadage/4ebdf56c7dbe326757dda5ca46618d04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JSX - JavaScript XML | |
var app ={ | |
title: 'Focus App', | |
subtitle: 'The TODO App', | |
options: ['One', 'Two'] | |
} | |
var template = ( | |
<div> | |
<h1>{app.title}</h1> | |
{app.subtitle && <p>{app.subtitle}</p>} | |
<p>{app.options.length > 0 ? 'Here are your options' : 'No options' }</p> | |
<p></p> | |
<ol> | |
<li>Item one</li> | |
<li>Item two</li> | |
</ol> | |
</div> | |
); | |
let count = 0; | |
const addOne = () => { | |
count++; | |
renderCounterApp(); | |
}; | |
const minusOne = () => { | |
count--; | |
renderCounterApp(); | |
}; | |
const reset = () => { | |
count = 0; | |
renderCounterApp(); | |
}; | |
var appRoot = document.getElementById('app'); | |
const renderCounterApp = () => { | |
const templateTwo = ( | |
<div className="container"> | |
<br></br> | |
<br></br> | |
<br></br> | |
<h1>Count : {count}</h1> | |
<button id="my-id" className="button btn btn-outline-danger btn-sm" onClick={addOne} > +1 </button> | |
<button id="my-id" className="button btn btn-outline-danger btn-sm" onClick={minusOne} > -1 </button> <br></br><br></br> | |
<button id="my-id" className="button btn btn-outline-danger btn-sm" onClick={reset} > Reset | |
</button> | |
</div> | |
); | |
ReactDOM.render(templateTwo, appRoot); | |
}; | |
renderCounterApp(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment