Open in app

Sign In

Write

Sign In

Jesse Chung
Jesse Chung

Home

About

May 19, 2022

Scroll and height

To have a percentage of viewing window use vh { overflow: scroll; max-height: 90vh; } Overflow scrolls means extra space will be scrolled

1 min read

1 min read


May 12, 2022

Bugs

Bugs

1 min read

Bugs
Bugs

1 min read


Apr 27, 2022

Regex troubles with a variable

var t = 'some sting characters ktestvarj'; var variables = { 'testvar': 123, 'testvar1': 456 }; function replacer(match, p1, offset, string) { return variables[p1]; } var modify = function (str) { var teststr = str.replace(/k(.*?)j/g, replacer); console.log(teststr); } modify(t); modify('some ktestvarj sting characters ktestvarj ktestvar1j');

1 min read

1 min read


Apr 8, 2022

Async without the need for promises

AsyncBatch = function(context) { var items = [], asycnCount = 0, onComplete, ctx = context || window; this.add = function(fn, params) { items.push({ fn: fn, params: params }); } this.run = function(callback) { onComplete = callback; for (var i in items) { items[i].fn.apply(this, items[i].params); } } this.done = function() { if ( ++asycnCount >= items.length ) { onComplete(); } } }

1 min read

1 min read


Apr 8, 2022

My promise example

var myPromise = new Promise((resolve, reject) => { SPA.checkEverwashDirectSingle(serviceLocation.id, async function (res1) { console.log(res1); resolve(res1) }) }); myPromise.then((value) => { pre.loadTemplate(‘page/locations/new.php’, function (template) { $(‘#content-container’).html(template({ location: {}, owners: owners, salespeople: salespeople, isEverWashDirect: value })); }); });

1 min read

1 min read


Mar 18, 2022

More efforts with typescript

export type Fruit = "Orange" | "Apple" | "Banana"; let myString: string = "Banana"; let myFruit: Fruit = myString as Fruit; Also notice that when using string literals you need to use only one | Edit As mentioned in the other answer by @Simon_Weaver, it's now possible to assert it to const: let fruit = "Banana" as const;

1 min read

1 min read


Feb 1, 2022

Problem

Is there a way to prevent local state from resetting when moving components between lists? · Issue… Example: https://codesandbox.io/s/488klj2y6x If you change the state of the components, and then move them to another…github.com React components keep resetting creating a problem. The best way to solve is to move the prop up and then use context to avoid prop drilling

1 min read

1 min read


Jan 26, 2022

React state not updating immediately?

React state not updating immediately? May 22, 2021 You update the state and you expect it to happen immediately but it doesn't. It might seems like the state…www.daggala.com The reason why the state doesn’t update immediately is because for each render, the state is immutable. You can see that … const [someState, setSomeState] = useState() …are both constants values ! So they’re immutable. The state remains constant inside the render but can be changed between two renders. …

1 min read

1 min read


Jan 25, 2022

Gitignore

https://stackoverflow.com/questions/45400361/why-is-gitignore-not-ignoring-my-files .gitignore only ignores files that are not part of the repository yet. If you already git added some files, their changes will still be tracked. To remove those files from your repository (but not from your file system) use git rm --cached on them. I used this to clear out a file, and then essentially they got removed but then readded during a the next commit. I chose the entire file

1 min read

1 min read


Jan 24, 2022

Today I learned

while using .src can be an option, it isn’t really a functional one for grabbing something from the component. I use relative paths for the initial link but the output on firefox is the absolute path making matching difficult Also, keyof typeof is the best way to make sure something is of the type options to the key of a specific enum let newFirst = event.currentTarget.id as keyof typeof ElementalColors;

1 min read

1 min read

Jesse Chung

Jesse Chung

Starting a tech bootcamp

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Text to speech