删除了 withRef 错误.要访问包装的实例,请在使用 Redux Form 时在连接的组件上使用 ref [英] Error withRef is removed. To access the wrapped instance, use a ref on the connected component when using Redux Form

查看:46
本文介绍了删除了 withRef 错误.要访问包装的实例,请在使用 Redux Form 时在连接的组件上使用 ref的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次尝试让 Redux Form 工作,但出现以下错误:

<块引用>

删除了 withRef 的不变违规.访问包装好的例如,在连接的组件上使用 ref.

我做错了什么?一旦我写入(从示例中复制/粘贴)商店,就会抛出错误.

这是代码.

从react"导入React;从react-dom"导入 ReactDOM;import { createStore, combineReducers } from 'redux'import { reducer as formReducer } from 'redux-form'const rootReducer = combineReducers({形式:formReducer})const store = createStore(rootReducer);功能应用(){返回 (<div className="应用程序"><h1>Hello CodeSandbox</h1><h2>开始编辑,看看神奇的事情发生了!</h2>

);}const rootElement = document.getElementById("root");ReactDOM.render(, rootElement);

我还制作了一个代码沙箱来显示这个问题:https://codesandbox.io/s/07xzolv60

解决方案

只需更新到最新版本的 redux-form (8.1.0).无需降级.

I am trying to get Redux Form to work for the first time and I am getting the following error:

Invariant Violation withRef is removed. To access the wrapped instance, use a ref on the connected component.

What am I doing wrong? The error is thrown as soon as I write (copy/paste from the example) the store.

Here is the code.

import React from "react";
import ReactDOM from "react-dom";
import { createStore, combineReducers } from 'redux'
import { reducer as formReducer } from 'redux-form'

const rootReducer = combineReducers({
  form: formReducer
})

const store = createStore(rootReducer);


function App() {
  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
    </div>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

I have also made a code sandbox that shows the issue: https://codesandbox.io/s/07xzolv60

解决方案

Just update to the latest version of redux-form (8.1.0). There is no need to downgrade.

这篇关于删除了 withRef 错误.要访问包装的实例,请在使用 Redux Form 时在连接的组件上使用 ref的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆