Week of July 16 2018 Flashcards
REACT:
What’s he name of the npm package for React Router
react-router-dom
REACT ROUTER:
What to import from React Router to create basic routes.
BrowserRouter, Route
REACT:
Conditional rendering inline. How to check if an array is empty?
array. length > 0 && ….(render component)
array. length alone will not work as this value has to be a true boolean (not just truthy or falsy)
REACT:
When to use parentheses in React components returning JSX?
- Parentheses are needed when explicitly returning multiple lines of code (in general in JS) , i.e. when using the ‘return’ keyword.
- Parentheses are not needed when implicitly (no return keyword) returning JSX in arrow functions (even multiple lines).
- Some (including Prettify) consider wrapping multiple lines of JSX in parentheses - even in the latter case - best practice.
JAVASCRIPT:
Explain ‘const’
(5 bullets)
- used to declare a constant
- values can only be assigned at time of declaration
- constants cannot be redeclared
- constants in JS are block scoped
- ES 2015 syntax
JAVASCRIPT:
What does immutable mean in Javascript?
- Immutable data types cannot be changed after they were created.
- JS primitive data types are immutable: strings, numbers, booleans, null, undefined, symbol (new in ECMAScript 2015).
- Changing a value will create a new value.
https://benmccormick.org/2016/06/04/what-are-mutable-and-immutable-data-structures-2/
JAVASCRIPT:
What does mutable mean in Javascript?
- Mutable data types are objects (including ES 2015 sets and maps).
- Changing a value will change the value in all references.
JAVASCRIPT:
What’s a ES 2015 alternative for a for loop?
for…of:
creates a loop iterating over iterable objects (arrays, strings, etc.)
REACT - Forms:
What’s the difference between HTML and JSX in “” elements of the type text?
None.
REACT - Forms:
What’s the difference between HTML and JSX in elements?
HTML:
- text content goes in between tags.
Content goes here
JSX: text content is assigned in value prop (similarly to text input)
REACT - Forms:
What’s the difference between HTML and JSX in dropdown elements and ?
Only difference is the by default selected option:
HTML (select by adding a select prop (no value)
One
Two
Three
JSX (select by setting select element’s value)
One
Two
Three
REACT:
Way to satisfy React’s (or React Router’s) requirement to return a single parent element without adding another div to the DOM?
Wrap with
INTERVIEWS:
What do interviewers likely want to learn when they ask you about projects?
Besides that they want you to be an active coder they want to see that you can articulate and describe technical issues. So go into implementation details!
REACT:
How to direct with React Router?
Use withRouter function supplied by react-router-dom and return the component from the function (wrap it) which gives you the history.push method.