Skip to content

Latest commit

 

History

History
135 lines (113 loc) · 4.89 KB

README.md

File metadata and controls

135 lines (113 loc) · 4.89 KB

Learning guide for React and javascript

Getting Started

Install MS Visual Studio it has minimal config and great performance.

OPTIONAL - Install Prettier

My Editor settings after installing these packages (using atom keybindings)

{
  "editor.tabSize": 2,
  "prettier.eslintIntegration": true,
  "eslint.autoFixOnSave": true,
  "prettier.semi": false,
  "window.zoomLevel": 1,
  "editor.formatOnSave": true,
  "javascript.format.enable": false,
  "atomKeymap.promptV3Features": true,
  "editor.multiCursorModifier": "ctrlCmd",
  "editor.formatOnPaste": true,
  "editor.renderWhitespace": "none"
}

Now you should be able to use the editor format shortcut to get amazing formatting instantly BAM!

1. Modern javascript and React

const FlexCentre = ({ children }) => 
  <div style={{ display: 'flex', justifyContent: 'center' }}>{children}</div>

OR

const FlexCentre = ({ children }) => 
  <div className="FlexCentre">{children}</div>

with

.FlexCentre {
  display: flex;
  justifyContent: center;
}
  • Use stateless components as much as possible e.g
const Button = ({ onClick, name }) => 
  <button onClick={onClick}>{name}</button>
  • Use proptypes whenever possible e.g
const ListOfNumbers = props => (
  <ol className={props.className}>
    {
      props.numbers.map(number => (
        <li>{number}</li>)
      )
    }
  </ol>
);

ListOfNumbers.propTypes = {
  className: React.PropTypes.string.isRequired,
  numbers: React.PropTypes.arrayOf(React.PropTypes.number)
};
  • Avoid functions in render as much as possible e.g
<button
 onClick={function}
 />

NOT

<button
 onClick={() => function()}
 />

ALSO watch out for this as it will call the function on each render

<button
 onClick={function()}
/>

Optional

2. More Javascript, testing and tooling for react

Optional

3. Emerging trends and advanced tooling

Optional

Resources

Great libraries worth a look

  • Lodash and lodash/Fp
  • date-fns
  • Rambda
  • FairyTale (Task)