我目前正在使用react-navigation
堆栈和选项卡导航。
每次用户导航到特定屏幕时是否可以重新渲染组件?我想确保componentDidMount()
每次到达特定屏幕时都重新运行,因此我通过调用适当的动作创建者从服务器获取最新数据。
我应该考虑哪些策略?我很确定这是一个常见的设计模式,但我没有看到记录的例子。
我正在为我的 React 应用程序使用 Material-UI@next。在一个特定组件中,我使用Expansion Panels显示项目列表。我还有一个简单的<Footer />
组件,如下所示:
import React, { Component } from "react";
import styled from "styled-components";
import Typography from "material-ui/Typography";
const FooterContainer = styled.div`
text-align: center;
position: absolute;
bottom: 0;
width: 100% !important;
height: 100px !important ;
background: #6cf;
`;
class Footer extends Component {
render() {
return (
<FooterContainer>
<Typography variant="title">Footer Text</Typography>
</FooterContainer>
);
}
}
export default Footer;
Run Code Online (Sandbox Code Playgroud)
这是我在<Footer />
项目列表下使用的代码片段:
render() {
return this.props.isFetching ? (
<Typography>Loading...</Typography>
) : (
<Container> …
Run Code Online (Sandbox Code Playgroud) 编辑:我发现这些被称为浮动通知.任何人都知道如何在Android设备上默认从应用程序(通过权限等)启用它们?
我目前正在Android设备上测试推送通知,并注意到虽然我收到推送通知,但它们不会弹出屏幕而是留在后台(我需要按照图片向下拖动顶部状态栏).我认为这是无用的,因为如果他正在使用手机,用户就不会得到通知:
在iPhone上,弹出窗口正确显示,没有任何问题.
我想了解Material-UI @ next网格布局系统.
我的目标是让两张纸在整个宽度屏幕上展开,并在屏幕变小到一张纸时断开.该文档包含以下代码段:
<Container>
<Grid container spacing={24}>
<Grid item xs={12}>
<Paper>xs=12</Paper>
</Grid>
<Grid item xs={12} sm={6}>
<Paper>xs=12 sm=6</Paper>
</Grid>
<Grid item xs={12} sm={6}>
<Paper>xs=12 sm=6</Paper>
</Grid>
<Grid item xs={6} sm={3}>
<Paper>xs=6 sm=3</Paper>
</Grid>
<Grid item xs={6} sm={3}>
<Paper>xs=6 sm=3</Paper>
</Grid>
<Grid item xs={6} sm={3}>
<Paper>xs=6 sm=3</Paper>
</Grid>
<Grid item xs={6} sm={3}>
<Paper>xs=6 sm=3</Paper>
</Grid>
</Grid>
</Container>
Run Code Online (Sandbox Code Playgroud)
然后我修改了代码,试图实现我只有两篇论文的目标,如下:
<Container>
<Grid container spacing={24}>
<Grid item xs={12} sm={6}>
<Paper>xs=12 sm=6</Paper>
</Grid>
<Grid item xs={12} sm={6}>
<Paper>xs=12 sm=6</Paper>
</Grid>
</Grid> …
Run Code Online (Sandbox Code Playgroud) 假设我正在使用Material-UI调色板,如下所示:
palette: {
primary: {
main: "#039be5",
light: "#63ccff",
dark: "#C218006db35B",
contrastText: "#fafafa"
},
secondary: {
main: "#f50057",
light: "#ff5983",
dark: "#bb002f",
contrastText: "#f9fbe7"
},
error: {
main: "#f50057",
light: "#ff5983",
dark: "#bb002f",
contrastText: "#f9fbe7"
}
},
Run Code Online (Sandbox Code Playgroud)
让我们说,我使用了一些材料的UI组件,如的<AppBar />
,<Button />
等他们每个人我想给他们的主要调色板对象的不同口音-恩。<AppBar />
将会primary.main
并且<Button />
将会primary.light
。
我该怎么做?
使用类似的东西<AppBar position="static" color="primary.light">
不起作用,并引发错误。
我正在尝试将下面 Drawer 组件的样式移植到 Styled Components 中。
<Drawer
variant="permanent"
classes={{
paper: classes.drawerPaper
}}
>
Run Code Online (Sandbox Code Playgroud)
,paper
样式如下:
const styles = theme => ({
drawerPaper: {
position: "relative",
width: 240px
}
});
Run Code Online (Sandbox Code Playgroud)
我不知道如何paper
通过 Styled Components自定义道具。以下样式组件语法不起作用:
export const StyledDrawer = styled(Drawer)`
position: "relative";
width: 240px;
`;
Run Code Online (Sandbox Code Playgroud)
该组件的源代码表明这是作为道具传递的,PaperProps
但我仍然找不到覆盖它的方法。
我希望能够通过在 Maven 发布插件 ( mvn -B release:prepare
) 中使用非交互模式来自动增加 Java 项目的发布版本。但是我不想使用默认的 Maven 版本控制架构。
我想使用的架构是<major>.<minor>.<bugfix>-SNAPSHOT
. 我确实设法在 pom 文件中执行此操作,但是 Maven 尝试按如下方式增加它:
1.0.0-SNAPSHOT
1.0.1-SNAPSHOT
1.0.2-SNAPSHOT
...
Run Code Online (Sandbox Code Playgroud)
但是我希望能够对此进行控制,虽然有时我确实有错误修正并且上述增量工作,但大多数时候我想发布次要版本,因此增量看起来像这样:
1.0.0-SNAPSHOT
1.1.0-SNAPSHOT
1.2.0-SNAPSHOT
...
Run Code Online (Sandbox Code Playgroud) 我正在使用 NodeJS 后端 API 服务器,它允许前端(ReactJS / React Native)使用表单数据上传图像。这是我正在使用的代码:
const s3 = new aws.S3({
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
region: "us-east-1",
});
...
const upload = multer({
storage: multerS3({
s3,
bucket: process.env.AWS_BUCKET,
acl: 'private',
metadata(req, file, cb) {
cb(null, {fieldName: file.fieldname});
},
key(req, file, cb) {
cb(null, Date.now().toString() + '.png');
}
})
})
...
app.post('/upload', upload.single('photo'), (req, res, next) => {
res.json(req.file)
})
Run Code Online (Sandbox Code Playgroud)
API 服务器正常工作,图像使用AWS_ACCESS_KEY_ID
和上传到私有安全存储桶中AWS_SECRET_ACCESS_KEY
。
但是现在我希望能够在 ReactJS 或 React Native 上渲染此图像。您是否建议构建另一个名为 like 的 NodeJS 路由/render
并以某种方式将其流式传输到后端?如果是,我该怎么做?
或者,我是否应该直接从前端渲染它并冒着将 …
我想让用户能够单击将当前 URL 复制到剪贴板的按钮。因为我只react-router
需要提取this.props.history.location.pathname
并将其附加到我的域名中。
第二部分是将其保存到剪贴板。如何才能做到这一点?另外,该解决方案是否仅限于某些浏览器?
这只是琐事/好奇心,因为我多次偶然发现这种情况.
是否可以缩短/解构以下类型的任务?
newValue = value.value
Run Code Online (Sandbox Code Playgroud)
天真的,我试过newValue = {value}
但它不起作用,因为该语法通常用于从具有相同键名的对象中解构变量.
reactjs ×7
material-ui ×4
react-native ×3
css ×2
expo ×2
amazon-s3 ×1
android ×1
devops ×1
ecmascript-6 ×1
java ×1
javascript ×1
maven ×1
node.js ×1