出于某种原因,当我想启动我的React Native项目时,它会停留在'Starting Packager ...'部分.我试图删除节点包,并重新安装它们,通过yarn,npm安装它们,但没有运气.我不知道应该怎么解决这个问题:/(太尴尬了)
今天,我制作了一个新的React Native应用程序,发现与上次创建本机应用程序有所不同。
type Props = {}
export default class App extends Component<Props> {}
Run Code Online (Sandbox Code Playgroud)
什么type Props = {};啊 我真的找不到任何东西。
我想做一个动态组件。(动态 TAG 将是一个样式组件 -> 情感)
const Dynamic = ({ tag: Tag, children, ...rest }) =>
   <Tag {...rest}>
      { children }
   </Tag>
Run Code Online (Sandbox Code Playgroud)
该组件将是一个样式组件,如:
const Column = styled(div)({ color: 'red' })
const Row = styled(span)({ color: 'yellow' })
Run Code Online (Sandbox Code Playgroud)
这看起来很好,而且工作正常,BUUUUUT:
当我尝试在另一个 DynamicComponent 中使用 DynamicComponent 时:
<DynamicComponent tag={Row}>
   {
      mapOver.map(item=>
         <DynamicComponent tag={Column}/>
      )
   }
</DynamicComponent>
Run Code Online (Sandbox Code Playgroud)
那么出于某种原因,动态子项将使用动态父项的样式。
有什么我想念的吗?
PS:
如果不是使用动态样式,我会这样做:
<Row>
   <Column/>
</Row>
Run Code Online (Sandbox Code Playgroud)
然后正确应用样式、类名、样式标签。
为了让它更清楚一点:
如您所见,DynamicComponent 将使用父级的样式、类名、样式标签......(不是我期望的行为)
我必须在视图中将按钮彼此相邻出于某种原因,即使我将视图设置为 alignItems: 'stretch' 或将项目设置为 alignSelf: 'stretch' 他们也不会用完可用空间。我怎么能解决这个问题?
例如:
<View style={{flexDirection: 'row', alignItems: 'stretch'}}>
    <View style={{backgroundColor: 'red', height: 100}}/>
    <View style={{backgroundColor: 'blue', height: 100}}/>
</View>
Run Code Online (Sandbox Code Playgroud)
视图不会拉伸,内部元素将保持宽度:0
或与按钮项目相同:
<View style={{flexDirection: 'row', alignItems: 'stretch'}}>
    <Button title='text' style={{backgroundColor: 'red', 
    height: 100}}/>
    <Button title='text' style={{backgroundColor: 'blue', 
    height: 100}}/>
</View>
Run Code Online (Sandbox Code Playgroud) 我刚刚安装了 react-native-image-crop。当我试图在真正的 iPhone 上拍照时,我收到了一个非常奇怪的错误。'App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.'. 这是因为我使用地铁建设者吗?或者别的什么?
我的信息.plist:
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>localhost</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>
Run Code Online (Sandbox Code Playgroud) 我只是用重新合成进行了HOC,但由于某种原因,所有传递下来的道具都触发了反应警告。
Warning: Unknown event handler property `onSaveChanges`. It will be ignored.
Run Code Online (Sandbox Code Playgroud)
我所有的属性都具有相同的语法(以小写开头,然后是大写:lowerUpper)。当然,如果我将它全部写成小写,那么它不会触发任何警告,但是如果我将HOC与recompose一起使用,我应该将所有道具都写成小写吗?
我的HOC:
import React from 'react'
import { withStateHandlers, withHandlers, withState, compose } from 'recompose'
const editableCell = (defaults) => 
    compose(
        withStateHandlers(
            { isEditing: false, value: ''},
            {
                toggleEditing: ({ isEditing, inputValue }) => defaultValue => ({
                    isEditing: true,
                    inputValue: isEditing ? inputValue : defaultValue
                }),
                onChange: () => event => ({
                    inputValue: event.target.value
                }),
                deactiveCell: () => () => ({
                    isEditing: false
                })
            }
        ),
        withHandlers({
            handleSave: ({ …Run Code Online (Sandbox Code Playgroud) 我想从一个对象访问一些数据,但不知道如何:/
exif:
   name: ''
   {GPS}:
Run Code Online (Sandbox Code Playgroud)
当我检查exif对象时,它有一个{GPS}参数,但不知道如何访问对象内的{}元素.