Advertisement
karlakmkj

React (JSX) - Variable Attribute in a Component

Jan 24th, 2021
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import ReactDOM from 'react-dom';
  3.  
  4. const owl = {
  5.   title: 'Excellent Owl',
  6.   src: 'https://content.codecademy.com/courses/React/react_photo-owl.jpg'
  7. };
  8.  
  9. // Component class starts here:
  10. class Owl extends React.Component{
  11.   render() {
  12.     return (
  13.       <div>
  14.       <h1> {owl.title} </h1>
  15.       <img
  16.         src = {owl.src}
  17.         alt = {owl.title} />
  18.       </div>
  19.     );
  20.   }
  21. }
  22.  
  23. ReactDOM.render(<Owl />, document.getElementById('app'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement