在AndroidManifest.xml中,我已删除“ orientation | screenSize”键:
class HomeScreen extends React.Component {
constructor(props) {
super(props)
this.state = {
orientation: width < height ? 'portrait' : 'landscape',
screenHeight:height,
screenwidth:width,
}
Dimensions.addEventListener('change', newDimensions => {
newScreenWidth = newDimensions.window.width;
newScreenHeight = newDimensions.window.height;
this.setState((newScreenWidth,newScreenHeight) => ({
orientation: newScreenWidth < newScreenHeight ? 'portrait' : 'landscape',
screenHeight:newScreenHeight,
screenWidth:newScreenWidth
}));
});
}
componentWillUnMount() {
Dimensions.removeEventListener('change', () => {});
}
当我在Android模拟器中更改方向时,将使用此“ setState”代码发生警告:
water.levels <- data.frame("Date" = ymd_hm(paste(1970, mt, dy, hr, sep = " ")),
"Year" = yr,
"Levels" = runif(376, min = 0.8, max = 1.5))
library(ggplot2)
ggplot(water.levels, aes(Date, Levels,
group = factor(Year),
colour = factor(Year))) +
geom_line()
我该怎么解决?...