小编Pet*_*ark的帖子

Firebase:如何使用Cloud Functions shell在本地运行"HTTPS可调用函数"?

我在Firebase官方指南中找不到此用例的解决方案.

  • 它们是HTTPS可调用函数
  • 想要使用Cloud Functions shell在本地运行函数进行测试
  • 函数将接收的数据保存到Firestore
  • 还需要'auth'上下文信息

我的代码如下.提前致谢.


功能:

exports.myFunction = functions.https.onCall((data, context) => {
  const id = context.auth.uid;
  const message = data.message;

  admin.firestore()...
  // Do something with Firestore //
});
Run Code Online (Sandbox Code Playgroud)

客户来电:

const message = { message: 'Hello.' };

firebase.functions().httpsCallable('myFunction')(message)
  .then(result => {
    // Do something //
  })
  .catch(error => {
    // Error handler //
  });
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-functions

12
推荐指数
1
解决办法
1345
查看次数

material-ui /如何使用'withStyles()'为HOC设置样式?

我的HOC:

const withPaper = Component => props => (
  <Paper>
    <Component {...props} />
  </Paper>
);

export default withPaper;
Run Code Online (Sandbox Code Playgroud)

我想使用以下样式设置“ Paper”组件withStyles()

const styles = theme => ({
  root: {
    backgroundColor: 'green'
  }
});

const withPaper = ?? => ?? => (
  <Paper className={classes.root}>
    <Component {...props} />
  </Paper>
);

export default withStyles(styles)(withPaper);
Run Code Online (Sandbox Code Playgroud)

我如何注入类来支持这种情况?我的简单想法Component => ({classes, ...props}) =>记录了错误。

TypeError:无法将类作为函数调用

material-ui jss

5
推荐指数
2
解决办法
2776
查看次数