Visual Studio Code:[js] types can only be used in a .ts file
Is it possible to use .js files in a typescript project in vs code? I have clone a react-native project from a github repository and opened it in visual studio code. When I add a tsconfig.json in order...
View ArticleWhy is State returning empty first in React TypeScript & Property does not...
I'm trying to work with state in react using typescript. In the line "return monster.name.toLowerCase().includes(search)" I'm getting this error message "Property 'name' does not exist on type...
View ArticleReact-Native wrapping a typed class into functional component for styling
I am wrapping components into functional components in order to perform consistent styling. This works pretty good most of the time, but if the wrapped component has generics in their properties things...
View ArticleReact Native content is not going to the next row
I am currently facing a styling issue. What am I trying to achieveI want to display a list of movies.There should be around two or three movies showed per row (depending on the available space on the...
View ArticleTypescript optional chaining error: Expression expected.ts(1109)
I am trying to do optional chaining in Typescript + React Native.Let's say I have the following interfaces:interface Bar { y: number } interface Foo { x?: Bar } and I try to run the following: const...
View ArticleReact Context Api
Im developing a products table with checkboxes on the side, the check box job is to send the Id of the choosen product once its clicked to it's grandfather so i can build an array of the choosen ones...
View ArticleWhy does eslint fail on Github Actions but works locally?
I have a workflow that looks like thisname: Node CI on: [push] jobs: build: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v1 - uses: actions/setup-node@v1 with: node-version: '12.x' - run: npm...
View ArticleWhy hasOwnProperty method doesn't eliminate {} type
I have a complex type ReactNode from @types/react 16.9.17 version and TypeScript v3.7.4 version.import React, { ReactNode } from 'react'; and I want to reduce this type to type, which has property...
View ArticleHow to test type definition file for react or react-native project?
I am a maintainer of a react and react-native library/sdk. We also provide type (typescript) definitions for the components that we export. But its a bit hard to manually keep actual components and...
View ArticleType 'Element | undefined' is not assignable to type 'FC | undefined'
In this MainHeader component:<MainHeader LeftButton={ previous ? ( <BackButton onPress={() => { navigation.goBack; }} /> ) : ( undefined ) } ... /> BackButton is a JSX element passed...
View ArticleReact Native referenced object seems to be undefined
I am trying to assign data retrieved from an API into an array, however whenever the data is called my project crashed and I get an error saying TypeError: undefined is not an object (evaluating...
View ArticleReact Native Typescript Formik typings of handleSubmit in onPress
I just started a project on React Native with Typescript and came along Formik in order to build form in my application.I did the great formik tutorial guide and saw the use of formik with RN section...
View ArticleReact Native -> React Native Web with webpack and JSX
I started a new React Native project (v61.5) with the TypeScript template (npx react-native init MyTSProject --template react-native-template-typescript). It compiles fine with React Native but when I...
View ArticleHow to use prop-types as type definition in typescript?
Situation:Consider having the myTypes constant holding prop-types (written somewhere in a file called my-component.js), like below:import React from 'react' import { View } from 'react-native' import...
View ArticleChange height of tab bar of createMaterialTopTabNavigator from child screen
Is there any way to change the height of createMaterialTopTabNavigator from inside a child screen?Basically - I have a request coming in from the server and in case there's no data - I need to show a...
View ArticleHow to catch unused variables with husky precommit
In my react/typescript project, I used no-unused-variable rule with tslint. So if there are no unused variables or imports it will block the commit. Now it says that, it has been deprecated and use...
View ArticleHot reload crashing after changing sub-file of "folder import"
I have a project setup that looks like this (use this as an MVCE):src/ styles/ index.ts common.ts app.tsx The code in index.js looks like this:import CommonStyles from "./common.ts"; export {...
View ArticleReact native webview can not open links on android
React native webview component can not open links on Android, but on IOS it works fine, without any troubles. Nothing has happening on Android, after the pressing, no any errors. At the same time i...
View ArticleTypeScript not parsing react-native-web code
Already tried suggestions here and here with no luckI have a project with a directory structure like this:. - /app - /web app is a react native app (created manually, not with...
View ArticleTypescript: tabBarOptions from createBottomTabNavigator
I was building a react-native app via expo init via its 3rd option, which creates basic navigation template in Javascript. And recently I was trying out the Typescript with the existing template and...
View Article