几个月以来,我面临一个非常奇怪的情况,在最新版本的 react native(0.50+ 到 0.60+)上开发时,iOS 模拟器停止响应键盘命令,即:
Hardware->Keyboard->Send Keyboard Shortcuts并启用它,命令将再次开始工作Cmd+Shift+H它不再工作了,所以如果我必须的话,我不能轻易关闭应用程序这真的让我发疯了,有没有人遇到过同样的情况或知道任何解决方法?非常感谢!
PS 我几个月前已经尝试过重置所有内容(包括模拟器设置和 xcode 安装)
假设我有以下样式:
const styles = StyleSheet.create({
padding: {
padding: 10
},
margin: {
margin: 10
}
});
Run Code Online (Sandbox Code Playgroud)
我想将它们都应用到反应组件中?
我在我的项目中使用 TailwindCSS,我想设置默认边框颜色,对于正常主题,我通过以下方式执行此操作:
module.exports = {
mode: "jit",
purge: ["{pages,app}/**/*.{jsx,tsx}", "node_modules/react-toastify/**"],
darkMode: "media",
theme: {
extend: {
borderColor: (theme) => ({
DEFAULT: theme("colors.gray.100"), // Light theme default border color
dark: {
DEFAULT: theme("colors.gray.800"), // Dark theme default border color NOT WORKING
},
}),
// ...
}
Run Code Online (Sandbox Code Playgroud)
对于浅色主题,它工作正常,但是,对于深色主题,我似乎找不到应用默认值的方法,关于如何使其工作有什么想法吗?
多谢!
我对打字稿和redux-thunk动作有一些不便.
基本上我的组件大量使用react-redux连接来绑定动作创建者,问题是,当我在组件中为这个redux动作创建接口时,我必须重新声明函数定义,因为它在连接调用时丢失了.
这是一个示例代码:
动作造物主
import api from './api';
import { Dispatch } from 'redux';
import { IReduxAction } from 'model';
export const FETCH_ENTITY = 'location/FETCH_ENTITY';
export function fetchEntity(id: string) {
return (dispatch: Dispatch<IReduxAction>) => {
dispatch({type: `${FETCH_ENTITY}_REQUEST`, payload: {id}});
return api.fetchEntity(id)
.then((res) => {
dispatch({ type: `${FETCH_ENTITY}_DONE`, payload: res });
return res;
})
.catch((err) => {
dispatch({type: `${FETCH_ENTITY}_FAIL`, payload: err, error: true});
throw err;
});
};
}
Run Code Online (Sandbox Code Playgroud)
零件
import * as React from 'react';
import { bindActionCreators } from 'redux'; …Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用了 tailwind css,由于我们的应用程序样式,我们使用的是默认字体颜色,但是我似乎无法在 tailwind 中找到如何执行此操作,文档页面仅讨论扩展调色板,但未讨论如何扩展设置默认颜色。
关于如何实现这一目标的任何想法?
嘿,我在尝试使用react-native-router-flux时获取当前场景关键。
我的路线文件:
const AppRouter = connect()(Router)
class Routes extends Component {
render() {
function selector(props) {
console.log(props)
// GoogleAnalytics.trackView(props.navigationState)
return props.auth.isLoggedIn ? (props.auth.isVerified? 'home': 'authenticate') : 'authenticate'
}
const component = connect(state => ({
auth: state.auth,
}))(Switch)
return (
<AppRouter>
<Scene key="root" component={component} tabs selector={selector} hideNavBar hideTabBar>
<Scene key="authenticate" hideTabBar>
<Scene type="replace" key="login" title="Login" initial component={GradientBackground(LoginScreen)} hideNavBar/>
<Scene type="replace" key="register" component={GradientBackground(RegisterScreen)} hideNavBar/>
<Scene type="replace" key="forgotPassword" title="forgotPassword" component={GradientBackground(ForgotPasswordScreen)} hideNavBar/>
<Scene type="replace" key="emailConfirmation" component={GradientBackground(EmailConfirmationScreen)} hideNavBar/>
</Scene>
<Scene key="home" component={NavigationDrawer} type="replace">
{require('./scenes/home')}
</Scene> …Run Code Online (Sandbox Code Playgroud) 所以我正在尝试使用 jest 和酶测试一些基于 material-ui 切换组件的功能。
我有一个通用的 clickIt 函数,它适用于其他 material-ui 组件,但在这个函数中它似乎没有触发状态更改
function clickIt(wrapper, selector) {
let elem = wrapper;
if (selector) {
elem = wrapper.find(selector);
}
const node = ReactDOM.findDOMNode(elem.node);
TestUtils.Simulate.touchTap(node);
}
Run Code Online (Sandbox Code Playgroud)
并在测试中:
const toggle = wrapper.find('#subscribe-toggle');
expect(toggle.props().checked).to.be(true);
clickIt(toggle);
expect(toggle.props().checked).to.be(true); // <- fails
Run Code Online (Sandbox Code Playgroud)
关于如何解决这个问题的任何想法?
我正在 react-native 上的 ios 上做一些图像处理。
问题是我使用的库之一只支持绝对路径,但我只有文件资产 uri。
例子
我有:
assets-library://asset/asset.HEIC?id=CE542E92-B1FF-42DC-BD89-D61BB70EB4BF&ext=HEIC
Run Code Online (Sandbox Code Playgroud)
我需要:
file:///Users/USERNAME/Library/Developer/CoreSimulator/Devices/########-####-####-####-############/data/Containers/Data/Application/########-####-####-####-############/Documents/########-####-####-####-############.jpg
Run Code Online (Sandbox Code Playgroud)
有什么方法可以轻松获取图像绝对路径?
我正在使用电子和打字稿启动一个新项目,我设置了该项目并运行了一个基本的 hello world,但是我尝试添加一个库(https://github.com/benjamn/recast),导入语法是不工作。
import React from 'react'; // Works
import { parse, prettyPrint } from 'recast'; // Does not work, cannot read property parse of undefined
import tsParser from 'recast/parsers/typescript'; // Does not work
// const recast = require('recast'); // Works
// const tsParser = require('recast/parsers/typescript'); // Works
Run Code Online (Sandbox Code Playgroud)
我的 webpack 配置和 tsconfig 如下:
webpack.rules.js:
module.exports = [
// Add support for native node modules
{
test: /\.node$/,
use: "node-loader"
},
{
test: /\.(m?js|node)$/,
parser: { amd: false }, …Run Code Online (Sandbox Code Playgroud) 所以我有一个相当复杂并使用新颖技术的项目,一方面我使用react-native-macos来构建macos应用程序,我还使用rxdb和一些本机sqlite连接器来存储数据,在任何案例,我面临一个奇怪的问题,我不知道它是什么时候开始的,但是现在,当我尝试使用 chrome 调试器来调试应用程序时,应用程序冻结并且调试器不显示任何内容,除了一些不平衡的警告:
如果未附加调试器,应用程序运行不会出现问题,但创建不带调试器的应用程序并不是真正的选择。
现在,可能有很多事情出了问题:
任何有关如何调试问题的提示将不胜感激!
PD 我试图平分我的 git 历史记录来尝试找到问题,但它太复杂/耗时,因为过去几周发生了重大编译/数据库更改
编辑:xcode 上有更多输出,但 chrome 上未显示:
2020-07-11 10:16:36.315968+0200 kipu[23727:437914] [] nw_socket_handle_socket_event [C7:1] Socket SO_ERROR [61: Connection refused]
2020-07-11 10:16:36.316257+0200 kipu[23727:437919] [] nw_connection_get_connected_socket [C7] Client called nw_connection_get_connected_socket on unconnected nw_connection
2020-07-11 10:16:36.316343+0200 kipu[23727:437919] TCP Conn 0x600003718000 Failed : error 0:61 [61]
2020-07-11 10:16:36.343 [info][tid:main][RCTPerformanceLogger.m:79] Unbalanced calls start/end for tag 16
Run Code Online (Sandbox Code Playgroud)
编辑2:现在我尝试使用react-native-debugger应用程序来调试应用程序,该应用程序在过去已经解决了一些问题,而且在这种情况下它似乎也允许它运行......所以我想现在我的问题已经解决了,我想这与我的 chrome 安装有关。
react-native ×5
reactjs ×4
javascript ×3
css ×2
ios ×2
tailwind-css ×2
typescript ×2
electron ×1
enzyme ×1
macos ×1
material-ui ×1
react-jsx ×1
react-redux ×1
redux ×1
routing ×1
simulator ×1
webpack ×1