react小记

组件间发通知可以使用

observer.pub,其他组件在
componentDidMount中
observer.sub。



在新的react中已经不再使用ref,取而代之的
onRef={
(node) => this.xxx = node
}
然后使用
this.xxx调用方法。

组件间共享数据可以使用redux

JSX语法解析变量中的换行符实现换行 

https://blog.csdn.net/Zckguiying/article/details/88641357

react-router 多路由共用同个组件,切换不刷新

https://blog.csdn.net/MingleHDU/article/details/92992809


antd相关
1、设置form表单初始值
form.setFieldsValue(obj);

form也可通过给子组件传入form属性获取子组件item的表单属性;

引入react后就是jsx文件;

antd 的form联动显示可以使用
form.getFieldValue('前一项')来控制显示后一项 

使用create-react-app

1、运行eject将config暴露;
2、配置package.json中的browserslist设置css的自动补全浏览器兼容版本
3、在router组件中使用link跳转
4、public中的文件打包后将不带版本号;
5、代码分割

其他
1、getDerivedStateFromProps 新生命周期

2、
<style jsx>{`
.search-result-wrapper .content-wrapper{
display: flex;
flex-direction: row;
}
`}</style>
在html中写样式css



原文地址:https://www.cnblogs.com/sunala/p/12576505.html