Passing a function prop from parent to child
We have a Parent component that contains the child component “ChildBtn”. Parent has the function parentFunction which is passed into the child. We can also specify the console log text and the button...
View ArticlePassing a function prop from child to parent
Using the same example as passing a function from parent to child but going in the opposite direction. Here the parent has a callback function and passes it to the child component. The child calls the...
View ArticleCSS Modules
CSS modules allow you to create unique class names even when the class is already used in another file. Name the file like so: name.module.css. Right normal css in it. Import the file like so: Apply it...
View ArticleDifference between document.ready and window.onload
Triggers when the HTML is ready. Use this to start running code as soon as possible. This is not jQuery. Trigger when everything on the page (eg images) is finished loading.
View ArticleDifference between var, let and const
var declarations are globally scoped or function scoped while let and const are block scoped. This means you can declare the a let or const with the same name inside an if statement and it will be self...
View ArticleAccessible hash links
This is mainly for the ‘skip to content’ links. $("a[href^='#']").not("a[href]='#'").click(function() { $("#"+$(this).attr("href").slice(1)+"").focus(); });
View ArticleUpdate all dependencies in package.json to latest
To do this, use npm-check-updates Install with Then update with
View ArticleCreating an array of empty arrays
If you do: let arr = new Array(5); arr.fill([]); This will make an array of 5 identical arrays where editing one will update all which is rarely what anyone wants. To achieve an array of different...
View ArticleCopying a state variable’s value
To copy the value of a variable declared using useState, if it’s an array use: let varName = [...stateVar]; If it’s not an array use: let varName = stateVar.valueOf();
View ArticleHow to fix NativeEventEmitter warning
I was getting the warning: new NativeEventEmitter() was called with a non-null argument without the required removeListeners method. I was using React Native Sound and to fix the warning I add the...
View ArticleHow to export an apk file for testing
In the terminal run these commands: Then the apk file is here:
View ArticleMaking a number only text input
On your input add this This will only allow number characters This will allow 1 decimal to be added in addition to numbers
View ArticleSword and Fairy 1 (2024) Drama Review – part 1
When I was a kid, I played a chinese RPG on PC called “The Legend of Sword and Fairy” (仙剑奇侠传) also known as ‘Chinese Paladin’. It was awesome, still is. One of my favourite games of all time. It just...
View ArticleSword and Fairy 1 (2024) Drama Review – part 2
Episode 22 So Bai Yue shows up and realistically with this many opponents he really shouldn’t be able to beat them. Mr Shi’s self sacrifice attack should also realistically damage him at least, but...
View Article