React Native - Image tag require warning

Viewed 59

In the code below, I try to display an image with a local path that I create to navigate to a specific directory in my project.

for example:

props.item.url = 'assets/logos/some-id/some-image-name.png'

<Image source={require(`../../../../${props.item.url}`)} style={{ width: "100%", height: "100%" }} resizeMode={"contain"} />

Look at the warning below, some warnings in different file are appear

Compiled with warnings. ./components/menu/sub-menu/new/templates/test.json Module parse failed: Unexpected token { in JSON at position 7651 while parsing near '... "direction": 1 }

{ "lock": 2, ...' You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders SyntaxError: Unexpected token { in JSON at position 7651 while parsing near '... "direction": 1 }

{ "lock": 2, ...' at JSON.parse ()

./services/localization/config/translate_thai.json Module parse failed: Unexpected token ​ in JSON at position 165 while parsing near '...TeamShortName" :{ ​ }, "TeamLo...' You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders SyntaxError: Unexpected token ​ in JSON at position 165 while parsing near '...TeamShortName" :{ ​ }, "TeamLo...' at JSON.parse ()

1 Answers
<Image source={{require("../picture/View.png")}} style={{height:"20%",width:"20%}}/>
Related