Skip to content

Dylanb-dev/Notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 

Repository files navigation

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)

About

Notes on React and javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published