Questions tagged [react-tsx]

A TypeScript XML syntax transform recommended for use with React.

TSX is an embeddable XML-like syntax. It is meant to be transformed into valid JavaScript, though the semantics of that transformation are implementation-specific. TSX rose to popularity with the React framework, but has since seen other implementations as well. TypeScript supports embedding, type checking, and compiling TSX directly to JavaScript.

563 questions
1
vote
0 answers

React currency input field with customInput example

I am trying to render customInput in React CurrencyInput field, What I have so far is: import { TextField, TextFieldProps } from '@mui/material'; import React from 'react'; import CurrencyInput from 'react-currency-input-field'; import { Controller,…
Wings
  • 502
  • 4
  • 14
1
vote
1 answer

Capacitor Filesystem API cannot find the relative path?

(Disclaimer: I am a newbie with React and Ionic) I am looking to implement capacitor's filesystem API into a React Component in order to read a JSON file that contains a simple string. My JSON file is in the same folder as my FileSystem.tsx…
1
vote
1 answer

How to get data correctly using the Spotify API with React

I have the following problem when I request data from the Spotify API, at first I get it, but when I reload the page or try to write this state using useState, an error 400 or 401 occurs. The code I use to get the data: ` import axios from…
1
vote
0 answers

How to test react component mocking fetch api?

I'm trying to test a react component where a fetch call occurs. The component: class SearchResults extends React.Component<{ tag: string; setSpinner: (value: boolean) => void }> { state: searchResultsState = { results: [], tag: '', …
Oksana
  • 25
  • 5
1
vote
0 answers

How to fix the errror " Binding element 'children' implicitly has an 'any' type.ts " for giving props to component in .tsx file?

I have written the code to make "Read more" functionality in ".tsx" file for my project. The code is: const ReadMore = ({ children }) => { const text = children; const [isReadMore, setIsReadMore] = useState(true); const toggleReadMore =…
1
vote
1 answer

useReducer type with optional dispatch

I need help with adding types to a reducer function with optional dispatch. Here's the source of the pattern. https://twitter.com/FernandoTheRojo/status/1521312171262681090?s=20&t=oerzPqJ8cb5Ts3sHVMH_5Q Here's the code: [on, toggle] = useReducer( …
Onat
  • 771
  • 1
  • 11
  • 17
1
vote
0 answers

Styled-components and Storybook should be used together?

Since Styled-component purpose is having a clean code without "className={}", "class={}" on my code, how can I use it with Storybook? For example, if I have a button that's gray and I need a red-error-variant, on Storybook I should have something…
1
vote
2 answers

Tsconfig show typescript file not found error after change file name

i changed an archive name from 'index.ts' to 'style.ts', after that always returns this error in tsconfig.json: "File '/src/components/AboutContainer/index.ts' not found. The file is in the program because: Matched by default include pattern…
1
vote
1 answer

React Type error on sending props data to component

Hi I've got this error since a long time and I can't figure how to resolved it. " ERROR in src/App.tsx:10:18 TS2322: Type '{ inputs: IFormInput[]; }' is not assignable to type 'IntrinsicAttributes & IFormInput[]'. Property 'inputs' does not exist on…
lcsaloon
  • 137
  • 10
1
vote
1 answer

Deploy react typescript Project on Heroku

How can I deploy a react typescript project on Heroku? can't seem to find any working build pack.
Ebenezar
  • 11
  • 2
1
vote
1 answer

How to convert methods from Library to fit functional component

Need help converting RNLocation.requestPermission and _startUpdatingLocation to work with function components in react native. Not sure how to approach this LatLon Component File import React, {useState} from "react"; import { SafeAreaView,…
1
vote
1 answer

React Redux Toolkit TS - Can't access class methods from my state objects

I have set up my redux store and I am able to edit my state objects and get their values. But for some reason I can't call methods on the state objects. It's as if they are stored as javascript objects. When I call getSequence() the first…
ohthepain
  • 2,004
  • 3
  • 19
  • 30
1
vote
1 answer

Map of Array Having Two Different Type of values in Type script

I am using react-typescript with vite. in my situation for arr interface I have option which is of type array of options or an array of strings. When I try to map and print them I am getting error on val.name which is any Property 'name' does not…
1
vote
0 answers

React TS - Form does not submit unless specific fields are filled + net::ERR_CONNECTION_RESET

I have a Curriculum Vitae form that does not send the data unless two sections are completely filled. For testing purposes none of the fields are required. Furthermore I am getting the error: POST http://localhost:8000/api/jobApplications…
FlyingR
  • 23
  • 4
1
vote
0 answers

How can I use react´s "TablerIcons" and svg´s "IconDefinition" types in a union?

So I´m using the mantine library in nextJS with Typescript and would like to use some svg-icons in the Navbar instead of just reacts TablerIcons. Imports: import { Icon as TablerIcon, Home2, Gauge, ... } from…
PhilBrk8
  • 11
  • 1