Week_1_Day_2: Components?


Day 2: Components?

Creating my first component. This included:
  • Creating a new 'StorePicker.js' file in the components directory.
  • Importing the required dependencies
  • Creating a class & returning JSX via render().
  • Importing the new component that I just created into the 'index.js' file.
My files now look like this:
index.js:

import React from 'react';  
import { render } from 'react-dom';

import StorePicker from './components/StorePicker';

render(<StorePicker/>, document.querySelector('#main'));

components/StorePicker.js

import React from 'react';

class StorePicker extends React.Component{  
  render() {
  return <p>Hello</p>
  }
}

export default StorePicker;  
This basic implementation seems pretty straight forward. I like the use of the es6 class and the basic requirements to always return at least one method (render() in this example).
[Video 3: Creating our First Components]

Post a Comment

0 Comments