Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

Type Casting For Object Typescript

export default function App() {
  const inputRef = useRef<HTMLInputElement | null>(null);
const car: {brand:string} = {
  brand: "Toyota"
}
  useEffect(() => {
console.log(car.brand);
  }, []);
  
  /*basically add :{} after the object name*/
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Type #Casting #For #Object #Typescript
ADD COMMENT
Topic
Name
2+5 =