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
0
votes
1 answer

Mock a class function used inside a React component

I'm trying to mock a function which is called inside my react component. Here is an exemple, with the function getContent(). How could I set my own return value in the test ? Component.test.tsx : describe('TEST', () => { it('test', () => { ... …
user676767
  • 41
  • 5
0
votes
2 answers

Mock a function used inside a react component "multiple times"

I am currently mocking an internal dependency in a react project this way: import { QueryClient, QueryClientProvider } from "react-query"; import { render } from "@testing-library/react"; import SectionCourses from "./SectionCourses"; const…
LuisEnMarroquin
  • 1,609
  • 1
  • 14
  • 26
0
votes
0 answers

Conflict Lint + Typescript React 18 / 'React' must be in scope when using JSX

I'm studying react 18 + typescript, and I have a problem. I have this code that has a problem. React import is not being used. But when I remove this import, in the return line it says "React must be in scope when using JSX". How can I remove that…
0
votes
1 answer

React Custom Component Parameter Is Not Defined

I'm currently using the Typescript version of reactjs and keep getting the error "message is not defined". This error is coming from line 5. import './App.css' import * as React from "react"; const MyComponent: React.FC = ({ message: string }) =>…
Kuno
  • 15
  • 3
0
votes
1 answer

How to set focus to another MUI element on Selection?

I have two MUI Select elements. After the user makes a selection on the first, I'd like the second to automatically get activated. Here's the pseudo-code: