In October last year (2024), my classmates and I applied for the PGWP. Yesterday, it was approved, ( some still waiting ) but not all of us received the same duration. Some were granted 3 years, while others only got 1 year and 8 months. I’m not sure why, as we are all classmates and took the same course, yet the durations are not equal. Do I need to request the same duration?
gloriousRead
u/gloriousRead
This is my component
// sample data
const object = {
name: "chair"
}
const Component = ({ object }) => {
const ValidationSchema = Yup.lazy(() =>
Yup.object().shape({
name: Yup.string().required(''),
}) );
try { ValidationSchema.validateSync({ name: object.name, });
// need some checking to run other func.
if (object.name === 'chair') {
// here's the block that doesn't trigger at all
console.log('this block not even triggering')
}
} catch (error) { console.log('this block triggering'); }
return(
<Formik />
)
};
I don
In my scenario, I want to separate static data to a different file let say content.js
then import in ComponentB. However, I'm not sure how to do it. I did tried below code but got an error I can't recall the exact message but something like this " Cannot use import statement outside something".
// ComponentA.js
const ComponentA = (props) => <div> {props.title} {props.description} ... </div>
// contents.js
import ComponentC from '...'
export const details = {
title: 'title A',
description: ComponentC, // A react component
... };
// ComponentB.js
import ComponentA from '...'
import { details } from '.
Personally, I liked ternary operator their awesome. However in my company we try to avoid nested ternaries.
For instance:
let optionA = false;
let optionB = true;
// NOT ALLOWED
<p style={{ fontSize: optionA ? '2rem' : optionB ? '3rem' : '1rem' }}>HEADER</p>
My approach is something like this.
const fontSize = (defaultOption = '1rem') => {
if (optionA) return '2rem'
if (optionB) return '3rem'
// add more...
return defaultOption
}
let optionA = false;
let optionB = true;
<p style={{ fontSize()}}>HEADER</p>
However, I'm thinking if there's an elegant way for this use case. I kind of thinking abou
Basically I want to access the list array however I got issue on it.
const data = [
{
id: 1,
list: []
},
{
id: 2,
list: []
}
]
// component A - Parent
const Parent = () => <Child entry={entry} />
// component B - Child
interface IProps<T> { entry: T[] }
const Child = <T,>({ entry}: IProps) => {
return (
<>
// I want to access the list []
// However got error Property 'list' does not exist on type 'T'.
{entry.map((item) => item.list)}
</>
)
}
Anyone knows this because I can't find touchpad shortcut key to on and off Lenovo yoga.
interface ElementStyle = {
// this section I'm confused with
// how to set empty object?// should I use any, unknown here?
}
type ButtonProps = {
label: string
elementProps?: ElementStyle
}
const SignedInBtn = ({ label, elementProps}: ButtonProps): JSX.Element => {
return(
<Button {...elementProps} >{label}</Button>
)
}
I have SignedInBtn component with props (label and elementProps)
elementProps is optional and empty object
I know I can use interface for object but how about for empty one? How do I properly set empty object type properly?
Don't get me wrong reactjs.org documentation is very informative I highly suggest reading the documentation itself before moving to other blogs.
But I know somehow there's a function based documentation example out there I just don't remember the site or link of it.
I do remember it was like reactjs.org but in function based example way no classes at all.
Anybody has this link or site on your bookmark?
Newbie here, I have simple code below, basically adding type props to my component but I got eslint error perhaps there's something wrong with my tsconfig settings or something else?
// actual code
import Box from '@mui/material/Box';
type Props = {
children: React.ReactChild[];
};
const Demo = ({ children }: Props) => {
return <Box>{children}</Box>;
};
export default Demo;
here's the eslint error message
I'm pretty new to typescript can someone explain to me or has links that can explain generics visually?
I have data coming from server and use the following values tags and Id's.
How do you improve this by adding extra edge cases if object keys "tags" and "id's" are exist or not I was thinking to use
if("tags" in obj) to check if keys are exist.
Any suggestion to improve this logic?
const data = [
{ tags: ['dogs'], id: '1' },
{ tags: ['cat'], id: '2' },
];
// isEmpty() from loadash
const getAnimal = (obj, keyword) => {
const result =
!isEmpty(obj) &&
obj
.filter(({ tags }) => tags.includes(keyword))
.map(({ id }) => id)
.toString();
`return re
For the first time i'm using apple wired keyboard on Windows 10, everything is working fine but the volume keys (F11 and F12) aren't. I tried and followed some YouTube tutorials most of suggestion is to install Apple bootcamp but for some reason it's not working on my Windows. Any guide please?! Bootcamp link
