小编Pra*_*mar的帖子

React JS/Typescript中的空合并运算符

我们有Null合并操作符.NET,我们可以使用如下

string postal_code = address?.postal_code;
Run Code Online (Sandbox Code Playgroud)

我们可以在React JS中做同样的事情吗?

我发现我们可以使用&&运算符

address.ts文件中

string postal_code = address && address.postal_code;
Run Code Online (Sandbox Code Playgroud)

我需要什么样的.net功能可以在typescript中使用react JS,这可能吗?

就像是:

string postal_code = address?.postal_code // I am getting the error in this line if I try to use like .NET
Run Code Online (Sandbox Code Playgroud)

.net javascript null-check typescript reactjs

7
推荐指数
2
解决办法
4342
查看次数

此实验性语法需要启用解析器插件:'exportDefaultFrom'

This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom'

我收到上述错误,而试图将整个应用程序从反应v15.6v16.2,通过使用迁移工具从Facebook等jscodeshift

javascript facebook reactjs jscodeshift

5
推荐指数
1
解决办法
6413
查看次数