由于某些错误,React-Native Flatlist没有Rendring

时间:2018-12-22 06:22:06

标签: javascript reactjs react-native listitem react-native-flatlist

平面列表实施,但数据无法正确呈现

App.js

C c; 
C d(c); 

MainComponent.js

defmodule SlugHelper do
  def slug(input, length \\ 30, acc \\ {"", ""})
  def slug("", _, {_, result}), do: result
  def slug(_, 0, {_, result}), do: result
  def slug(<<"-", _::binary>>, 1, {acc, result}), do: result
  def slug(<<"-", rest::binary>>, length, {acc, ""}), do:
    slug(rest, length - 1, {"", acc})
  def slug(<<"-", rest::binary>>, length, {acc, result}), do:
    slug(rest, length - 1, {"", result <> "-" <> acc})
  def slug(<<chr::binary-size(1), rest::binary>>, length, {acc, result}),
    do: slug(rest, length - 1, {acc <> chr, result})
end

string = "another-long-string-to-be-truncated-and-much-text-here"
Enum.each(20..30, & string |> SlugHelper.slug(&1) |> IO.puts())

#⇒ another-long
#  another-long-string
#  another-long-string
#  another-long-string
#  another-long-string-to
#  another-long-string-to
#  another-long-string-to
#  another-long-string-to-be
#  another-long-string-to-be
#  another-long-string-to-be
#  another-long-string-to-be

MenuComponent.js

import React, {Component} from 'react';
import Main from './components/MainComponents';
import {Platform} from 'react-native';



const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' + 'Cmd+D or shake for dev menu',
  android:
    'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});


export default class App extends Component<Props> {
  render() {
    return (
        <Main />

    );
  }
}

错误

您可能忘记了导出组件,或者混淆了默认设置和命名导入

我已经阅读了所有与之相关的问题,但不适用于我 新手反应本机

高度重视帮助

谢谢

1 个答案:

答案 0 :(得分:2)

由于菜单组件是默认导出,因此您无法像{Menu}一样导入它

在您的MainComponent.js中

更改

   import {Menu} from './MenuComponent';

收件人

   import Menu from './MenuComponent';

更改

import Main from './components/MainComponents';

收件人

import Main from './components/MainComponent';