在我的iOS模拟器上,它们都返回相同的值.
我理解普通浏览器的区别,但React Native有什么区别?是否存在返回不同值的情况?
我玩Docker Swarm,并使用docker-compose.yml带docker deploy.除了一个处于挂起状态的服务之外,所有服务都会被部署.我添加了一个约束,将此服务绑定到其中一个节点.我的问题不是关于这个特定的问题,而是关于如何排除故障的更多问题.Docker文档提到了服务处于挂起状态的可能原因,但这些都不适用(约束问题,资源排放).
我可以在某个地方看到码头工人群'思考过程'吗?它在想什么?
编辑:应该更明确我使用新的1.12引入的swarm选项.
文档根本没有提到这一点。是否允许嵌套作用域定义,如果允许,web/router.ex 中以下内容的定义行为是什么:
scope "/:locale", MyApp do
pipe_through [:browser, :locale]
scope "/auth", MyApp do
pipe_through [:auth]
get "/", PageController, :dummy
end
get "/", PageController, :dummy
end
Run Code Online (Sandbox Code Playgroud)
管道是否链接,即 /:locale/auth 请求是否通过 :browser、:locale AND :auth 路由?有什么问题吗?
这与我当前的问题无关,但更像是一般情况。有时我会遇到一个仅在生产配置中发生的问题,我想在那里进行调试。在Elixir中解决此问题的最佳方法是什么?生产在没有图形环境的情况下运行(泊坞窗)。
在开发人员中,我可以使用IEX.pry,但是由于无法在生产中使用mix,因此似乎不是一种选择。
对于Erlang,https: //stackoverflow.com/a/21413344/1561489提到了dbg和redbug,但是即使可以使用它们,我也需要帮助将它们应用于Elixir代码。
我正在尝试将我的 React 项目转移到 Typescript,但没有 Typescript 经验。我有一个组件,其定义如下(精简):
interface InputProps {
handleKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
placeholder: string;
style?: React.CSSProperties;
}
const Input: React.ForwardRefRenderFunction<HTMLInputElement, InputProps> = (
^^^^^
{ handleKeyDown, placeholder, style }: InputProps,
ref: React.MutableRefObject<HTMLInputElement | null>
): JSX.Element => {
return (
<input
ref={ref}
onKeyDown={handleKeyDown}
type="text"
placeholder={placeholder}
style={style}
/>
);
};
export const ForwardedInput = React.forwardRef(Input);
Run Code Online (Sandbox Code Playgroud)
现在我在 上收到以下 TypeScript 错误const Input,这对我来说有点太复杂了,无法解决:
TS2322: Type '({ handleKeyDown, placeholder, style }: InputProps, ref: React.MutableRefObject<HTMLInputElement | null>) => JSX.Element'
is not assignable …Run Code Online (Sandbox Code Playgroud) 我有一个语法错误,我不知道它从哪里来。这是我的功能(在persona_from_auth.ex中):
# find or create the user.
# if you login with oauth2, your account will auto created
def find_or_create(%Auth{provider: :github} = auth) do
with
{:notfound} <- check_github_email(auth.info.email),
{:notfound} <- check_google_email(auth.info.email)
do
create(auth)
else
{:ok, persona} -> update(auth, persona)
end
end
Run Code Online (Sandbox Code Playgroud)
这将返回以下错误:
== Compilation error on file web/models/persona_from_auth.ex ==
** (SyntaxError) web/models/persona_from_auth.ex:18: syntax error before: do
(elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1
Run Code Online (Sandbox Code Playgroud)
第18行是create()调用之前的行。
我检查了正确的长生不老药版本。在mix.exs中发现我有1.2,我将其更改为1.4.2,但仍然是相同的错误。编译是否仍可能使用1.2?我该如何检查?
我想在 Expo 管理的项目中使用酶来测试我的 React-Native 组件。我遵循jest-expo-enzyme的文档,但现在我得到:
Test environment found at "/Users/raarts/myproject/node_modules/jest-environment-enzyme/lib/index.js" does not export a "getVmContext" method, which is mandatory from Jest 27. This method is a replacement for "runScript".
Run Code Online (Sandbox Code Playgroud)
我的猜测是jest-environment-enzyme(上次发布是在 2 年前),jest 27 需要以某种方式进行更新,但考虑到jest-expo-enzyme是在 2 个月前发布的,我想我一定是做错了什么。不知道如何继续。
有人有什么建议吗?
我在我的腿上找到了一个 ios 应用程序的源代码(从 2016 年底开始),现在我正在尝试在模拟器中构建并运行它。我刚刚学习 React Native。
完整的错误消息在这里:
Unable to resolve module prop-types from /Users/raarts/work/MobileApp/app/node_modules/react-redux/lib/components/Provider.js: Module does not exist in the module map or in these directories:
/Users/raarts/work/MobileApp/app/node_modules/react-redux/node_modules
, /Users/raarts/work/MobileApp/app/node_modules
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cache`.
RCTFatal
-[RCTBatchedBridge stopLoadingWithError:]
__25-[RCTBatchedBridge start]_block_invoke_2
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun …Run Code Online (Sandbox Code Playgroud) 为什么会失败:
%Partner{} |> cast(%{id: 123}, [:id]) |> delete
Run Code Online (Sandbox Code Playgroud)
用Ecto.NoPrimaryKeyValueError? 我正在明确设置主键?
我试图同时注销并清除商店,因此单击我会发送以下内容:
dispatch({type: PURGE, key: 'root', result: () => { } });
Run Code Online (Sandbox Code Playgroud)
Redux persist 捕获它,并报告清除存储。伟大的。在另一个减速器中,我捕获该调度,并删除我的访问令牌,如下所示:
import { PURGE } from 'redux-persist/es/constants';
const authSlice = createSlice({
name: 'auth',
initialState,
reducers: {
setAccessToken(state: AuthState, action: PayloadAction<Auth>): void {
state.accessToken = action.payload.accessToken;
state.expiresIn = action.payload.expiresIn;
},
},
extraReducers: {
[PURGE]: (state: AuthState, action: string): void => {
state.accessToken = initialState.accessToken;
state.expiresIn = initialState.expiresIn;
},
},
});
Run Code Online (Sandbox Code Playgroud)
PURGE 减速器实际上被调用,并修改状态,但仍然没有重新渲染发生。所以 redux 一定不能接受它。但根据文档,Redux 工具包使用 Proxy 对象作为状态,并进行比较以查看它是否被修改。
我尝试过的事情:
state = initialState;
Run Code Online (Sandbox Code Playgroud)
和
state = { ...initialState };
Run Code Online (Sandbox Code Playgroud)
没用。商店可以工作,可以保存数据,其他操作也可以工作。我该如何继续? …
是不是ES6替换节点require()?我有以下代码:
var sprintf = require("sprintf-js").sprintf;
这与广告一样有效.我可以使用sprintf().我想使用ES6 import语句完成相同的操作:
import sprintf from 'sprintf-js';
这不起作用.为什么不?我该如何解决?如果您可以解释sprintf-js中的导出如何工作,则可以获得奖励积分.
这是我的主要 App 类:
return(
<Provider store={store}>
<View style={ { flex: 1, paddingTop: paddingTop } }>
<MainScreenNavigator/>
</View>
</Provider>
)
Run Code Online (Sandbox Code Playgroud)
哪个有效。但是,如果我尝试将其包装在这样的登录名中:
return(
<Provider store={store}>
<View style={ { flex: 1, paddingTop: paddingTop } }>
<Login>
<MainScreenNavigator/>
</Login>
</View>
</Provider>
)
Run Code Online (Sandbox Code Playgroud)
使用 Login 类如下:
class Login extends Component {
render = () => {
return (
<View>
{this.props.children}
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)
没有任何东西被渲染。我不明白。
elixir ×4
react-native ×4
reactjs ×2
docker ×1
docker-swarm ×1
ecto ×1
enzyme ×1
erlang ×1
expo ×1
javascript ×1
jestjs ×1
node.js ×1
react-redux ×1
typescript ×1