Skip to content

Instantly share code, notes, and snippets.

{
items.map(({ name, tongueWidth, weight } = {}) => (
<div style={{ margin: '25px 0' }}>
<div>Name: {name}</div>
<div>Width of their tongue: {tongueWidth}cm</div>
<div>Weight: {weight}lbs</div>
</div>
))
}
const hasInvalidChars = /^.*?(?=[\+\^#%&$\*:<>\?/\{\|\}\[\]\)\(]).*$/g.test(
inputValue,
)
const callApi = async (keywords) => {
try {
const url = `https://someapi.com/v1/search/?keywords=${keywords}/`
return api.searchStuff(url)
} catch (error) {
throw error
const hasInvalidChars = /^.*?(?=[\+\^#%&$\*:<>\?/\{\|\}\[\]\\\)\(]).*$/g.test(
inputValue,
)
import React, { useState, useEffect } from 'react'
const useUploadStuff = () => {
const [files, setFiles] = useState([])
// Limit the file sizes here
const onChange = (e) => {
const arrFiles = Array.from(e.target.files)
const filesUnder5mb = arrFiles.filter((file) => {
const bytesLimit = 5000000
const someFunction = function() {
const store = {
people: {
joe: {
age: 16,
gender: 'boy',
},
bob: {
age: 14,
gender: 'transgender',
const someFunction = function () {
const store = {
people: {
joe: {
age: 16,
gender: 'boy',
},
bob: {
age: 14,
gender: 'transgender',
"TypeError: Cannot read property 'age' of undefined
at tibeweragi.js:24:29
at https://static.jsbin.com/js/prod/runner-4.1.7.min.js:1:13924
at https://static.jsbin.com/js/prod/runner-4.1.7.min.js:1:10866"
const store = {
people: {
joe: {
age: 16,
gender: 'boy',
},
bob: {
age: 14,
gender: 'transgender',
}
import { useReducer } from 'react'
const initialState = {
//
}
const reducer = (state, action) => {
switch (action.type) {
default:
return state
{
"const initialState = {}; const reducer = (state, action)": {
"prefix": "rsr",
"body": [
"const initialState = {",
" //$1",
"}",
"",
"const reducer = (state, action) => {",
" switch (action.type) {",