自己整理RN

rn onpress={()=>hanshu(para)} 可以传参
onpress={(index,val)=>this.haha(index,val)}
传递组件内自带参数
//
style={this.colorjudge(i, j, cell)}
/
/遍历所有子组件
return React.Children.map(props.children, child => {}
{}显示子组件
return (

{props.children}
/// RN PropTypes可以指定属性值的类型 style={{justifyContent: 'center', alignItems: 'center'}} 可以作为modal的垂直水平居中 /// webview 可以将整个网页展示在app上 textAlignVertical: 'top', 如果为true,则文本放置可以输入多行文字。替换为false。注意安卓上如果设置multiline = {true},文本替换会垂直居中,可设置textAlignVertical: 'top'样式来替换居顶显示。 // const rightButtons = [


getdevicesfromprops 用法
static getDerivedStateFromProps(nextProps, state) {
const oldData = JSON.stringify(state.reload);
const newData = JSON.stringify(nextProps.reload);
if (oldData != newData) {
new Myaccordion(nextProps).tesrt();
}
const oldData2 = JSON.stringify(state.prevpropsweekstype);
const newData2 = JSON.stringify(nextProps.weekstype1);
console.log(newData2, ‘2323’);
console.log(oldData2, ‘232311’);
console.log(oldData2 != newData2);
if (oldData2 != newData2) {
console.log(‘54545454’);
console.log(‘aaaaaaa’);
const data = nextProps.weekstype1 || ‘全部’;
return {
weekstype: data.length > 0 ? nextProps.weekstype1 : ‘全部’,
prevpropsweekstype: nextProps.weekstype1,
};
}
const oldData1 = JSON.stringify(state.chanceplanweek);
const newData1 = JSON.stringify(nextProps.chanceplanweek);
if (oldData1 != newData1) {
console.log(‘45454545454545’);
const data = nextProps.chanceplanweek || ‘周’;
return {
chanceweek: data.length > 0 ? nextProps.chanceplanweek : ‘周’,
prevpropschanceweek: nextProps.chanceplanweek,
};
}

return null;

}

new Myaccordion(nextProps).tesrt();这里面的setState不会执行
这意味着即使你的props没有任何变化,而是state发生了变化,导致组件发生了re-render,这个生命周期函数依然会被调用
https://blog.csdn.net/weixin_34007886/article/details/87997179
//
chushidata.forEach((item, index) => {
item.list.forEach((item1, index1) => {
if (item1.status == 2) {
item.list.splice(index1, 1);
if (item.list.length == 0) {
chushidata.splice(index, 1);
}
}
});
if (item.list.length == 0) {
chushidata.splice(index, 1);
}
});
这样写代码可以修改内循环遗留下来的遗漏

gradle版本有插件版和其他版本,需要注意

tableData: [
[’’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’],
[’’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’],
[’’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’],
[’’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’],
[’’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’],
[’’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’],
[’’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’],
[’’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’],
[’’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’],
[’’, ‘’, ‘’, ‘’, ‘’, ‘’, ‘’],
给这样的数据做判断时,根据
style={this.colorjudge(i, j, cell.course_name)}>
在对数据进行判断时cell===’’ 不对cell===underfined则正确

rn 中的getDerivedStateFromProps 和componentWillReceiveProps不推荐使用,可以使用给组件加key解决

onSelect={(index, val) => this.DropdwonSelect(index, val, totalindex)}
index, val是自带参数,totalindex是外部参数写后面

Invariant Violation: [53303,“RCTView”,1,

{“position”:“absolute”,“height”:“auto”,“borderWidth”:0.7511736685610308,“borderColor”:-2894893,“borderRadius”:2,“backgroundColor”:-1,“justifyContent”:“center”,“width”:225,“top”:"<>",“left”:333.5211181640625}] is not usable as a native method argument

使用的react-native-modal-dropdown展开的位置超过scrollview的展示范围

<FlatList data={[{key: ‘a’}, {key: ‘b’}]} renderItem={({item}) => {item.key} } />

item外面有个{}

Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.

<DatePicker
defaultDate={this.defaultDate(totalindex)}???写错了

defaultDate={()=>this.defaultDate(totalindex)}???写错了
应该这个样子
defaultDate = i => {
let dateTime = new Date();
let dateTime2 = dateTime.setDate(dateTime.getDate() + 2);
let datetime3 = new Date(dateTime2);
let fabubei = this.state.fabubeikebaototal;
fabubei[i].endtime = datetime3;
// this.setState({fabubeikebaototal: fabubei}, () => {});
return datetime3;
};

RN对absolute的官方解释就是:以父元素的边框为基准进行偏移,也就是说只能在父元素包裹的范围内偏移;

react-native android绝对定位时点击事件失效

使用flatlist时下面的点击按钮不了

flatlist初始内容决定他的高度,主要还是因为flatlist外层view不应该包含点击按钮

marginTop: scaleSizeH(110),

rn的zindex必须套在父元素上,不然无法浮在父元素的兄弟元素上

rn的键盘默认会顶起modal框,在设置modal框宽高100,键盘会浮起来

Invariant Violation: [app.model] namespace should be unique

**
export default [login, main, home, publishedHomeWork, paint, global, webPaint, forum,cache];**

在redux里cache重名了

rn 跟界面渲染有关放在this.state,其他放在this

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值