小编use*_*079的帖子

React Native - NativeBase组件在iOS上不占用全宽

在使用NativeBase构建的iOS版本的本机应用程序中,除非给出特定的宽度,否则一切都太瘦了.见下图.我给页眉和页脚的宽度为100%,所以它很好,但我没有为输入做到这一点,他们太瘦了.当没有宽度时,页眉和页脚是瘦的.

在此输入图像描述

码:

import React from 'react'
import {
  Container,
  Header,
  Form,
  Item,
  Input,
  Label,
  Content,
  Footer,
  FooterTab,
  Button,
  Left,
  Right,
  Body
} from 'native-base'

import { Text, Image } from 'react-native'

export const Volcalc = () => {
  return (
    <Container style={styles.container}>
      <Header style={styles.header}>
        <Left>
          <Image resizeMode={Image.resizeMode.contain} style={styles.thumbnail} source={require('./img/logo_red_nowords.png')} />

        </Left>
        <Body>
        </Body>
        <Right />
      </Header>

      <Content>

        <Form>
          <Item stackedLabel bordered >
            <Label>height</Label>
            <Input />
          </Item>
          <Item stackedLabel >
            <Label>width</Label>
            <Input />
          </Item>
        </Form>

      </Content>

      <Footer >
        <FooterTab style={styles.footer}>
          <Button …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android native-base react-native-ios

8
推荐指数
2
解决办法
7654
查看次数

如果只有组件的一部分发生变化,React 是否会渲染整个组件?

我想知道如果我将大组件拆分成许多非常小的组件,我的代码是否会更高效,以便应用程序一次只渲染 DOM 的较小部分。

但是我觉得 React 可能已经只渲染了应用程序发生变化的部分,无论组件是大还是小。所以如果一个庞大组件的一小部分被改变,React 只会重新渲染组件的那一小部分,而不是整个组件。

我在第二段中的断言是否正确,或者我可以通过将一个大组件分成许多小组件来获得更好的性能吗?我在这个问题中包括 ReactJS 和 React Native。我认为它们在这方面是相同的,但如果它们不同,我想知道。

reactjs react-native react-native-android react-native-ios

7
推荐指数
1
解决办法
8289
查看次数

使用es6数组方法从数组中提取第一个对象

我有以下代码来获取一个对象的数组:

let selectedShop = initialResultsState.get('products')
        .filter(product => product.shop.selected)
Run Code Online (Sandbox Code Playgroud)

console.log(selectedShop)

结果:

在此处输入图片说明

我是否可以通过在另一操作中将另一个es6数组方法插入字符串的末尾filter而不是这样做从数组中提取对象let newVariable = selesctedShop[0]

我试图把它串起来:

.map(x => {return { shop: x.shop, products: x.products }})
Run Code Online (Sandbox Code Playgroud)

但它仍然是一个对象的数组,因为map总是返回一个新数组。

javascript arrays ecmascript-6

6
推荐指数
2
解决办法
2274
查看次数

自定义字体在React Native中不起作用

我想在我的应用中使用Google字体中的一种字体。这是字体

我已将.ttf文件放在中app/fonts

package.json:

{
    "name": "xxx",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "start": "node node_modules/react-native/local-cli/cli.js start",
        "test": "jest"
    },
    "rnpm": {
        "assets": ["./app/fonts"]
    },
    "jest": {
        "preset": "react-native",
        "moduleNameMapper": {
            "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
            "\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
        }
    },
    "dependencies": {
        "flow-typed": "^2.0.0",
        "immutable": "^3.8.1",
        "react": "~15.4.1",
        "react-native": "0.42.0",
        "react-native-vector-icons": "^4.0.0",
        "react-redux": "^5.0.3",
        "redux": "^3.6.0",
        "redux-immutable": "^4.0.0",
        "redux-observable": "^0.14.1",
        "rxjs": "^5.2.0"
    },
    "devDependencies": {
        "babel-eslint": "^7.1.1",
        "babel-jest": "19.0.0",
        "babel-preset-react-native": "1.9.1",
        "eslint": "^3.17.0",
        "eslint-plugin-flowtype": "^2.30.3",
        "eslint-plugin-jsx": "^0.0.2",
        "eslint-plugin-react": "^6.10.0",
        "eslint-plugin-react-native": …
Run Code Online (Sandbox Code Playgroud)

android ios reactjs react-native

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

将param传递给`connect()`中的mapStateToProps

如何将参数传递给mapStateToProps()

例如:

const mapStateToProps = (state, dimenType: string) => {

  var jsonVariable = {}
  for(var i=1; i <= 3; i++) {
    jsonVariable[dimenType + i] = dimenType + i
  }
  console.log(jsonVariable)
  return {
    width1: state.get('width').get('width1').toString(),
    width2: state.get('width').get('width2').toString(),
    width3: state.get('width').get('width3').toString()
  }
}
Run Code Online (Sandbox Code Playgroud)

这是我不确定的一点:

Width = connect(
  mapStateToProps(/*redux store goes here somehow*/, 'thickness'),
  mapDispatchToProps
)(Width)
Run Code Online (Sandbox Code Playgroud)

我希望redux商店仍然可以传递,mapStateToProps但也通过"thickness".我该如何在connect()函数中执行此操作?

reactjs react-native redux react-redux

4
推荐指数
1
解决办法
3085
查看次数

创建没有无限实例化的实例

这一行:mdv = new MapDesignerView();创建一个无尽的实例化(无限循环).请参阅下面的代码:

public partial class MapDesignerView : Form
{
    public  MapDesignerView mdv;
    public  Map map;
    public  MapController mapController;
    public MapConstructor mapConstructor;
    MouseEventHandler detectMouse;

    public MapDesignerView()
    {
        mdv = new MapDesignerView();
        map = new Map(mdv);
        mapController = new MapController(map);
        mapConstructor = new MapConstructor(mapController);
        detectMouse = new MouseEventHandler(mapController);
        InitializeComponent();
    }
}
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我需要在MapDesignerView类中创建类的实例mapDesignView,以传递给另一个类构造函数.如何以不同的方式将此表单传递给Map构造函数,以便它无法无限实例化?

c# constructor winforms

3
推荐指数
1
解决办法
97
查看次数

数据序列化WPF

对不起,这个问题似乎很愚蠢.我已经研究了一些关于这个主题的网页,但我不确定它们对我的问题有多重要.我有一个2D地图设计师.我想保存地图,以便我可以加载它并在其上玩游戏.我对序列化很新,我想知道我应该研究哪些文档,以及是否有人可以指向一些与我的序列化任务相关的网页.这是数据结构:

    public class ModelMap
    {
        public ModelMap()
        {
            this.cellBgImage = new Image();
            this.exitImage = new Image();
            this.theseus = new Image();
            this.minotaur = new Image();
        }

        public int rows { get; set; }
        public int cols { get; set; }
        public int boardXPos { get; set; }
        public int boardYPos { get; set; }
        public int myCellSize { get; set; }
        public Image cellBgImage { get; set; }
        public string HorizontalWallSource { get; set; }
        public string VerticalWallSource { get; set; …
Run Code Online (Sandbox Code Playgroud)

c# wpf serialization deserialization

3
推荐指数
1
解决办法
7616
查看次数

redux-observable动作必须是普通对象。使用自定义中间件进行异步操作

当我getCurrentPositionEpic在以下代码中注释掉时,该应用程序正常运行。但是,如果我不加注释,则会出现错误:

动作必须是普通对象。使用自定义中间件进行异步操作。

export const rootEpic = combineEpics(
  fetchCategoriesEpic,
  getCurrentLocationEpic,
  getCurrentPositionEpic
)

const store = createStore(
  rootReducer,
  initialState,
  composeWithDevTools(
    applyMiddleware(createEpicMiddleware(rootEpic))
  )
)
Run Code Online (Sandbox Code Playgroud)

location.epic.js

const getCurrentPosition$ = getCurrentPositionObservable(
  { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 }
)

getCurrentPosition$.subscribe(
  (position) => {
    console.log(position)
    const positionObject = {
      lat: position.coords.latitude,
      lng: position.coords.longitude
    }
    //store.dispatch(updateRegion(positionObject))
    //getCurrentLocation(positionObject)
  },
  (err) => {
    console.log('Error: %s', err)
  },
  () => {
    console.log('Completed')
  })

export const getCurrentLocationEpic = action$ =>
  action$.ofType(GET_CURRENT_LOCATION)
    .mergeMap(() =>
      Observable.fromPromise(Geocoder.geocodePosition(makeSelectLocation()))
        .flatMap((response) => Observable.of(
          getCurrentLocationFulfilled(response) …
Run Code Online (Sandbox Code Playgroud)

react-native redux rxjs5 react-redux redux-observable

3
推荐指数
1
解决办法
967
查看次数

运行.cs文件 - visual studio 2012

我刚开始用visual studio 2012和windows 8开始学习c#,本教程给出了一些.cs文件,但没有解释如何运行它们.这是本教程中的所有命令行内容.这个堆栈溢出答案提供了最容易听到的方式(响应其他人的类似问题).

如果您已经安装了Visual Studio,请执行以下操作:单击"开始",指向"所有程序",指向"Microsoft Visual Studio",指向"Visual Studio工具",然后单击"Visual Studio命令提示符",您可以在其中输入命令行框,如下所示:

csc PathToYourCsSource

我找不到visual studio工具.我在Windows 8中将其键入搜索.谢谢

c#

2
推荐指数
1
解决办法
2万
查看次数

MSDN C#Arrays教程

我正在从MSDN教程学习C#数组语法.它有这个代码:

// Array-of-arrays (jagged array)
byte[][] scores = new byte[5][];

// Create the jagged array
for (int i = 0; i < scores.Length; i++)
{
    scores[i] = new byte[i + 3];
}

// Print length of each row
for (int i = 0; i < scores.Length; i++)
{
    Console.WriteLine("Length of row {0} is {1}", i, scores[i].Length);
    Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)

并说输出是:

Length of row 0 is 3
Length of row 1 is 4
Length of row 2 is 5
Length …
Run Code Online (Sandbox Code Playgroud)

c# arrays

2
推荐指数
1
解决办法
377
查看次数