Noor
Noor
TTCTheo's Typesafe Cult
Created by Noor on 6/28/2024 in #questions
Small Dynamic in Static Website
I have a website which is fully static. Now in my blog posts which is also static I want to have likes (or number of likes user gave to that article) type of small dynamic thing. But I don't want to give the static website just for this small dynamic thing and don't want to implement the site in React or Nextjs How can I do this? I am thinking of creating a whole different site and adding that small part as iframe to my static site. Do you have any other suggestions?
3 replies
TTCTheo's Typesafe Cult
Created by Noor on 6/1/2024 in #questions
How to create 4 button in CSS
No description
5 replies
TTCTheo's Typesafe Cult
Created by Noor on 3/11/2024 in #questions
Change BG using React State
Hey everyone, So I have a page with different radio buttons bg1, bg2,....bg10 That page is in a different route For eg: /themes/ Now whenever the user changes the radio button I want to change the background image of the whole document with user type How can I do this in React?
4 replies
TTCTheo's Typesafe Cult
Created by Noor on 3/8/2024 in #questions
DB or Localstorage?
Hey everyone, I want to store the settings/preference of users For example If I have to store color preference, theme preference, sound preferences or any settings related preferences So should I store it in Database and every time user loads the react app, it will be fetched and those settings will be applied Or should I store them in localstorage and then apply settings??
25 replies
TTCTheo's Typesafe Cult
Created by Noor on 3/7/2024 in #questions
React Lazy Load Required Files
I have 20 to 25 mp3 files in my react app. User have the ability to setup any one song. The problem is whenever the React app loads, all the songs are imported by default. But i want to import only one song which user have selected so the app can load faster. I have created customhook useSound which takes song name and it return the mp3 file. Below is the code. // File 1, where useSound is used
const getSound = useSound('song1');
getSound.volume = 0.5;
getSound.play();
const getSound = useSound('song1');
getSound.volume = 0.5;
getSound.play();
// File 2: useSound Implementation
import song1 from "../../assets/songs/song1.mp3"
import song2 from "../../assets/songs/song2.mp3"
...
import song25 from "../../assets/songs/song25.mp3"

export const useSound = (value) => {
if (value == "song1") return new Audio(song1);
if (value == "song2") return new Audio(song2);
...
if (value == "song25") return new Audio(song25);
}
import song1 from "../../assets/songs/song1.mp3"
import song2 from "../../assets/songs/song2.mp3"
...
import song25 from "../../assets/songs/song25.mp3"

export const useSound = (value) => {
if (value == "song1") return new Audio(song1);
if (value == "song2") return new Audio(song2);
...
if (value == "song25") return new Audio(song25);
}
Can anyone help and tell me a better approach for this?
5 replies
TTCTheo's Typesafe Cult
Created by Noor on 3/2/2024 in #questions
Best Chart/Graphs React Library
Hey everyone I am working on react app. I want to introduce analytics and analysis of data in the app. Currently I am not decided what type of Charts or Graphs to use. So can anyone suggest me best library for react which js light weight, easy to use and have many options to choose from.
7 replies
TTCTheo's Typesafe Cult
Created by Noor on 2/29/2024 in #questions
Time Comparison
I have two times startTime: "18:10" endTime: "18:55" Now I want to compare the current time with these So if the current time is before startTime I want to return -1 If the current time is after the end time I want to return 1 And if the current time is between start and end time I want to return 0 I tried to implement using if else but it's getting to Complex and its not accurate too. Can anyone help me build logic for this?
3 replies
TTCTheo's Typesafe Cult
Created by Noor on 2/29/2024 in #questions
State update without dispatch
I have an react app in which my state is maintained by Context Provider and useReducer. The state is an array. I have used state.arr.sort() function And it sorted the arr But how come it modified the state data when I haven't used the dispatch here??
1 replies
TTCTheo's Typesafe Cult
Created by Noor on 2/29/2024 in #questions
How to sort object based on time (HH:MM)
Hey everyone, I have an object as below const arr =[ { id: 123, time: "10:58" }, { id: 727, time: "16:00" }, { id: 343, time: "10:12" }, ... ] I want to sort this array based on time, like whichever object has earlier time should be above than the object which has time later.
15 replies