ReactJs开发问题

1.关于不能在函数组件上使用 ref 属性的问题

Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()

官方方案:如果要在函数组件中使用 ref,你可以使用 forwardRef(可与 useImperativeHandle 结合使用),或者可以将该组件转化为 class 组件。

2.与类型“IntrinsicAttributes & IntrinsicClassAttributes<Component<Pick<FormComponentProps<any>, "wrappedComponentRef">, any, any>> & Readonly<...> & Readonly<...>”不具有相同的属性

解决方案:export default Form.create<any>()(AxSelectTable);

 3.Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.

出现这个问题的原因之一:组件都被销毁了,还设置组件的state

4.ssr服务端渲染,window对象是不可用的(render failed ReferenceError: window is not defined)

 

posted on 2020-06-30 22:34  dbolodb  阅读(918)  评论(0编辑  收藏  举报