Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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();
Add Comment
Please, Sign In to add comment