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 (
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