Jsx2 exercise discussion

Here is my solution. Thank you.

let pElement = React.createElement(‘p’, null, ‘Lorem, ipsum’);
React.createElement(‘div’, {id:“hello”}, pElement);

2 Likes
React.createElement( "div", { id: "hello" }, 
  React.createElement("p", null, "Lorem, ipsum.")
);
2 Likes

React.createElement(
“div”,
{id: “hello”},
React.createElement(
“p”,
null,
“Lorem, ipsum.”)
);

1 Like

The gist of it:

1 Like
React.createElement('div', {
  id: 'hello'
}, React.createElement('p', null, 'Lorem, Ipsum'));
2 Likes
React.createElement("div", {id:"hello"}, React.createElement("p", null, "Lorem, ipsum"));
2 Likes

React.createElement(
“div”,
{
id: “hello”
},
React.createElement(
“p”,
null,
“Lorem, ipsom.”
)
);

written correctly

React.createElement(
“div”,
{
id: “hello”
},
React.createElement(
“p”,
null,
“Lorem, ipsom.”
)
);

2 Likes
React.createElement(
"div", 
{id: "hello"}, 
React.createElement("p", null, "Lorem, ipsum.")
);
2 Likes
<div id="hello">

<p>Lorem, ipsum.</p>

</div> 
React.createElement("div", {
                     id: "hello"
                    }, React.createElement("p",
                                            null, 
                                            "Lorem, ipsum."));
2 Likes
React.createElement("div", {
  id: "hello"
},React.createElement("p", null, "lorem ,ipsum."));
2 Likes
React.createElement(

  "div",

  null,

  "Lorem, ipsum."

)
3 Likes
<div id="hello">
    <p>
        Lorem ipsum.
    </p>
</div>
React.createElement("div", {
  id: "hello"
}, React.createElement("p", null, "Lorem ipsum."));
2 Likes
Demo 3 - Jsx 2 Exercise
<!-- Don't use this in production: why - babel should be run before you upload code to the web page. -->
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>

Jsx 2 Exercise

Some usseless text generated by React

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad necessitatibus sed fuga earum aliquid minima. Quasi dolores iure rerum, adipisci ex porro fugiat iusto vel voluptatibus molestiae soluta mollitia consectetur.

Nobody sees this coming

nore this

class Hello extends React.Component { render() { return React.createElement('div', null, `${this.props.messagetxt}`); //besure to use ` and not ' }; }
  ReactDOM.render(
      React.createElement(Hello, 
       { messagetxt: 
        'marry had a little lamb chop whose fleas were as white as snow. And every where marry went the smell was sure to follow'
       }, null), 
      document.getElementById('marry')
  );

  // some more useless text
  ReactDOM.render(
      React.createElement(Hello, 
       { messagetxt: 
        'people will generally do the right thing ... after exhausting all the other possibilities'
       }, null), 
      document.getElementById('people')
  );

   // some even more useless text
   ReactDOM.render(
      React.createElement(Hello, 
       { messagetxt: 
        'when my kids start whining about something I tell them "Harden up mate! or you will never be THE MAN your monther was"'
       }, null), 
      document.getElementById('mykids')
  );

</script>
1 Like

React.createElement("div", {id: "hello"}, 
    React.createElement("p", null, "Lorem, ipsum.")
);

1 Like
"use strict";

/*#__PURE__*/
React.createElement("div", {
  id: "hello"
}, /*#__PURE__*/React.createElement("p", null, "Lorem, ipsum."));
2 Likes

The code seems generated due to the PURE comment. If you wrote it yourself, then you don’t need it, it’s just FYI from the generator/transpiler.

1 Like

React.createElement(“div”, { id = “hello” },
React.createElement(“p”, null, “Lorem, ipsum.”)
);

2 Likes

React.createElement(“div”, {
id: “hello”
}, React.createElement(“p”, null, “Lorem, ipsum.”)
);

@Lizette I’m stuck in the Class components 2 class , since there is no forum link to that class, I thought it might be a good idea to post it here … could you please let Zsolt know this? … I did everything exactly as he is doing it, and I cannot get my table displayed… this is my result … just an empty table :sob:

and this is my code:

Name Ticker Price
class Coin extends React.Component {
  /*
  constructor(props) {
    super(props)
  }
  */
  render(){
    return (
      <tr>
        <td>(this.props.name)</td>
        <td>(this.props.ticker)</td>
        <td>(this.props.price)</td>
      </tr>
    );
  }

}



ReactDOM.render(
  <React.Fragment>
    <Coin name="Bitcoin" ticker="BTC" price="$13300.00" />
    <Coin name="Polkadot" ticker="DOT" price="4.09" />
  </React.Fragment>,
    document.getElementById('root')
);

React.createElement(
  React.Fragment,
  null,
);

</script>