JS and React.js Flashcards
To learn technical jargon
Linting
Software that screens code for syntax errors while differentiating various elements of code
I.D.E.
Integrated Development Environment
D.O.M.
Document Model Object
What must every component do?
*Render some code to the DOM
What 3 arguments are accepted by .createElement?
1) HTML Element
2) Configuration (JS object)
3) Children of Element
Var vs Const
Var: can change
Const: data never changes
Functional Components are written
const cmp = () => { return <div>some JSX</div> }
Class Components are written
class Cmp extends Component { render () { return <div>some JSX</div> } }
Dynamic Code within a JSX Element must be wrapped in?
Single curly braces:
{ dynamic code }
Children
Any Element that is contained between a Components opening and closing tags
Props
Used to dynamically pass code from parent components to child components
Dynamic Code
Not hard coded, code easily able to change
State
Is managed from within a component and if changed will cause a re-render.
Handlers
Class methods that are not actively being called but is triggered by an event
Should State should be mutated?
No
Mutate
To hard change data
How do you inject JS expressions into JSX?
With single curly braces { }
Turnery Operator
? = (if) \: = (else)
.Map( ) does what?
Executes a method on an array
Where is JSX written in React projects
After the Return
Where is JS written in React projects
After the Render
To properly use .Map( ) in needs to be placed on which Element?
The outer most Element
What is a good file structure for a React App?
Src >
Components > (Components)
Assets > (Images)
What is special about PureComponents
They have shouldComponentUpdate checks built in
What is a HOC?
A Higher Order Component
What is the proper way to update State within a setState call?
setState( ( prevState, props ) => { return {
statefulElement: prevState.method }
}
)
How do ‘Switch’ statements work?
Switch statements take an expression which is evaluated against a set of CASEs to look for the first CASE with the matching expression. If no CASE matches the provided expression then a DEFAULT case is executed. Switch statements fun until a BRAKE is encountered. If more than one CASE matches the Switch will execute the first match and its associated statements.
How should you name Global Constants?
In all CAPS and with _ between words.
withRouter( ) gives you access to witch 3 methods?
.match( ), .history( ), and .location( )
What is “escaping” in JS?
Escaping is using a / to tell the computer that the symbol coming after the backslash is to be interpreted as a string not as a operational value.
What are the 6 JavaScript values?
1) Strings
2) Numbers
3) Booleans
4) Objects
5) Functions
6) Undefined
What is an “Expression”?
An expression is a combination of values that are computed by the computer. An Expression results in a value.
What is a “Statement”?
Statements are computer instructions. A Statement preforms a task.
What are semi-colons used for in JS?
A semi-colon is used to separate statements.
What is a Function?
A function is a repeatable block of code that executes certain actions and preforms tasks. You execute a function by calling it. This is also know as invoking the function.
Koans
code learning website
What does the Modulus operator do?
Returns the amount left over after a division.