Skip to content

Instantly share code, notes, and snippets.

View verdi327's full-sized avatar
💭
Thinkful EI

Michael Verdi verdi327

💭
Thinkful EI
View GitHub Profile
@verdi327
verdi327 / validation-message.js
Last active May 2, 2019 20:16
Functional component for rendering form errors
function ValidationMessage(props) {
if (!props.valid) {
return <div className='error-msg'>{props.message}</div>
}
return null;
}
@verdi327
verdi327 / validating-username.js
Last active May 2, 2019 20:29
form-validation-example-1
//Step One - set state
state = {
username: '', usernameValid: false,
formValid: false,
errorMsg: {}
}
// Step Two Part A - Add onChange to form field (inside your render fn)
<div className='form-group'>
<label htmlFor='username'>Username</label>
@verdi327
verdi327 / blackbox
Created April 30, 2019 15:06 — forked from cklanac/blackbox
blackbox node_modules and internals
node_modules
^(assert|buffer|crypto|events|fs|net|util|url|path|timers|_http_server|_http_common|_http_incoming|_http_outgoing|_stream_writable|_stream_readable|_stream_duplex)\.js
@verdi327
verdi327 / context.txt
Created April 24, 2019 15:17
context overview
UserContext.js
-define the user context
const UserContext = React.createContext({
name: 'Joe',
setName: () => {}
});
--
@verdi327
verdi327 / generator.js
Created April 23, 2019 12:14
Create React App File Generator Script
const fs = require("fs");
const nodeFS = require("node-fs");
const argv = require('yargs')
.usage('Usage: npm run generate [component] [relative/to/src]')
.describe('relative/to/src', 'allows nested directory creation from ./src folder')
.example('npm run generate FooList')
.example('npm run generate FooList Components/Foo')
.demandOption(['component'])
.help()
.argv;
@verdi327
verdi327 / something.js
Last active April 22, 2019 17:41
js async/await
increment = async () => {
await this.setState({value: this.state.value + 1})
this.setState({
values: [...this.state.values, this.state.value]
})
}
@verdi327
verdi327 / .eslintrc.json
Created April 19, 2019 14:52
example .
{
/**
* ESLint: http://eslint.org/docs/user-guide/configuring
*/
"globals": {
"$": true
},
// "env:" supplies predefined global variables
@verdi327
verdi327 / api-documentation.txt
Created April 2, 2019 13:50
Understanding API Documentation
Youtube Subscription List Endpoint
Required: part - string:
Value Options: contentDetails, id, snippet, subscriberSnippet
Optional 1:
forChannelId: String
Description: The forChannelId parameter specifies a comma-separated list of channel IDs.
The API response will then only contain subscriptions matching those channels.
Optional 2:
@verdi327
verdi327 / diagram-request-response.JPG
Last active April 2, 2019 02:13
describing the request/response cycle
diagram-request-response.JPG
@verdi327
verdi327 / shopping-list.user-stories.js
Created March 29, 2019 15:53
Shopping List Pseudo Code
function addNewItem(store, name) {
// create a new item object
// add it to the store array
}
function toggleCompleted(store, name) {
// find item by name in the store array
// update the completed property to be the opposite of what it is currently
}