在使用typescript和react + redux时遇到问题
Could not find a declaration file for module 'react-redux'. '/home/andrew/miramir/src/js/node_modules/react-redux/lib/index.js' implicitly has an 'any' type.
正在尝试从react-redux获取提供程序
import { Provider } from 'react-redux';
我怎么才能修复它?谢谢
我正在使用react-redux和typescript,所以我有.tsx文件。我的简单代码看起来非常简单和明显,但是typescript编译器抛给我一个Provider元素的类型错误,所以我不知道我做错了什么。
下面是我的简单代码
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { Route, Router } from 'react-router
我遵循JavaScript中的redux教程,但是当我用TypeScript编写时,我无法将状态映射到道具。
App.tsx
import * as React from 'react';
import Todo from '../models/Todo';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import Main from './Main';
export interface State {
您好,我正在尝试建立一个简单的redux计数器示例在React原生使用Typescript使用此文档https://enappd.com/blog/redux-in-react-native-app/92/,即使该文档使用javascript我正在尝试将代码移植到typescript中。但是我得到了一些错误。这是我的代码。Ps react原生的typescript样板代码是由官方RN文档中使用的Typescript模板完成的 Counts.ts import {COUNTER_CHANGE} from '../constants';
export function chan
我刚刚在我的create应用程序类型记录项目中安装了MUI v5.4,我想导入
import { createTheme } from '@mui/system';
但是埃斯林特一直在显示这个错误
'@mui/system' should be listed in the project's dependencies.
@mui/system位于package.json中的依赖项中。
"dependencies": {
"@babel/plugin-proposal-private-property-in-object
我制作了一个非常简单的react+redux应用程序,但是只要执行任何操作,我就会在浏览器控制台中收到7条关于useMemo参数不匹配的警告。以下是第一项:
Warning: The final argument passed to useMemo changed size between renders. The order and size of this array must remain constant.
Previous: [[object Object]]
Incoming: [[object Object], function () {
// Distingu
我正在尝试使用Preact + Vite + Typescript + Redux构建一个简单的Todo应用程序。但是我面临着一些与redux和类型记录的兼容性问题。
这就是我要犯的错误。
Uncaught TypeError: Cannot read properties of undefined (reading '__H')
at m (react-redux.064eb876.js:3)
at d (react-redux.064eb876.js:3)
at d.Provider [as constructor] (react-redux.064
我用Typescript安装了React项目: npx create-react-app my-app --template typescript 在我使用npm run start运行应用程序之后 我得到了这个错误: TypeScript error in C:/Users/neman/Desktop/projects/redux-saga-ts-boilerplate/src/index.tsx(2,22):
Could not find a declaration file for module 'react-dom'. 'C:/Users/neman/Desk
我有简单的功能组件,如下所示。
import React, { useState } from 'react';
import { connect } from 'react-redux';
import JoinRoomInputs from '../../../components/JoinRoomPage/JoinRoomInputs/JoinRoomInputs';
import { State } from '../../../store/states/states';
interface Props {
is
我正在使用React 和Jest来测试我的React/Redux应用程序。
我想在多个测试中测试相同的组件,而不是在每个实例之间共享组件的状态。
就像这样..。
import React from "react";
import {renderWithRedux} from '../testUtils';
import App from "../components/App";
describe("App", () => {
test("does something as expected", a
我是react-redux的新手。我有这个代码,我正在使用react,redux和TypeScript。在这段使用基于类的组件的代码中,我想使用dispatch来调用动作来增加counter的值,但这给了我以下错误。
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of Re
我有以下TypeScript (v3.01) React组件,名为TopBar,我现在将Redux添加到其中。然后在名为Layout的父组件中引用TopBar组件。
import * as React from 'react';
import { connect } from "react-redux";
import { decrementZoomLevel, incrementZoomLevel, setCenterPoint, setZoomLevel } from '../store/actions';
class TopBar ex
我在新的应用目录中使用redux工具包时遇到了麻烦。是否有一种特殊的方法来实现提供程序,因为到目前为止,我尝试过的一切都失败了。
下面的过程与现有的页面目录.完美地工作
import "../styles/globals.css";
import type { AppProps } from "next/app";
import { Provider } from "react-redux";
import { store } from "../store";
import Navbar from "./Navbar