我是React Native(和React)的新手,我正在尝试将一个函数作为prop传递给一个组件.
我的目标是创建一个组件,其组件的实例化器可以设置其onPress功能,以便它更具可重用性.
到目前为止,这是我的代码.
App.js
import React, { Component } from 'react';
import { View } from 'react-native';
import TouchableButton from './components/touchable-button';
export default class App extends Component<Props> {
constructor () {
super();
}
handlePress () {
// this should be called when my custom component is clicked
}
render () {
return (
<View>
<TouchableButton handlePress={this.handlePress.bind(this)}/>
</View>
);
}
}
Run Code Online (Sandbox Code Playgroud)
TouchableButton.js
import React, { Component } from 'react';
import { TouchableHighlight } from 'react-native';
import AppButton from "./app-button";
export …Run Code Online (Sandbox Code Playgroud) 我正在创建一个程序,其中大量使用 UUID 来识别用户和组等内容。鉴于 UUID 已被占用的可能性极低,我是否应该担心发生冲突的可能性?
我开始更多地进入网络开发。目前,我将 Spark 框架与 Vue 一起用于我制作的少数应用程序。虽然这当然有效,但并不理想。
该项目是使用 Maven(以及用于 Vue 的 NPM)构建的,构建过程如下所示。
所以文件系统看起来像这样
/src/main/java(Spark 框架)
/src/main/resources (Vue)
这会导致一些烦恼。
所以我的问题是:构建应用程序的更好方法是什么?
我有以下代码:
module FunctorsApplicativeFunctorsAndMonoids(List(..), combineLists) where
data List a = Empty | Value a (List a) deriving (Eq, Show)
combineLists:: List a -> List a -> List a
combineLists (Value a rest) b = Value a (combineLists rest b)
combineLists Empty b = b
Run Code Online (Sandbox Code Playgroud)
我编写了此测试以确保行为按我的预期工作:
module FunctorsApplicativeFunctorsAndMonoidsSpec where
import Test.Hspec
import FunctorsApplicativeFunctorsAndMonoids
spec :: Spec
spec = do
describe "List" $ do
it "should implement combineLists" $ do
combineLists (Value 1 Empty) (Value 2 Empty) `shouldBe` (Value 1 (Value 2 Empty)) …Run Code Online (Sandbox Code Playgroud) haskell ×1
java ×1
javascript ×1
maven ×1
node.js ×1
react-native ×1
reactjs ×1
uuid ×1
vue.js ×1