react-native

React native - FETCH - Authorization header not working

耗尽温柔 提交于 2021-02-11 16:47:26
问题 I made a server query via an app developed using react-native. I used fetch API and it turns out any query with authorization header not working. POST and GET method REQUESTS that don't expect Authorization headers at the server side works well. Some Queries at the server side are protected with authorization and when I make such queries including authorization header, I always get '401:unauthorized' error. But such queries works well with POSTMAN. Any suggestions here would be of great help.

Window.location.reload() in react-native

自闭症网瘾萝莉.ら 提交于 2021-02-11 16:45:47
问题 I often use window.location.reload on my React Web project. window.location.reload(); Is there any similar way to reload page(component) in react-native? 回答1: The thing that you mention is a browser feature. React Native uses native capabilities to render your app, so there are no browser features like window.location.reload() So I am not sure what is your particular use-case for this. I guess it is needed to reload the current screen, not the full app. In this case, you should use a react

./gradlew assembleRelease build failing when updated to react native 59.8 & gradle to 5.1

只谈情不闲聊 提交于 2021-02-11 15:31:35
问题 Before updating react-native to 59.8 and gradle to 5.1, I can take build using ./gradlew assembleRelease. When I updated react native to 59.8 and gradle to 5.1, I got following error * What went wrong: Execution failed for task ':react-native-app-settings:verifyReleaseResources'. > java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed \node_modules\react-native-app-settings\android\build\intermediates\res\merged\release

./gradlew assembleRelease build failing when updated to react native 59.8 & gradle to 5.1

让人想犯罪 __ 提交于 2021-02-11 15:31:26
问题 Before updating react-native to 59.8 and gradle to 5.1, I can take build using ./gradlew assembleRelease. When I updated react native to 59.8 and gradle to 5.1, I got following error * What went wrong: Execution failed for task ':react-native-app-settings:verifyReleaseResources'. > java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed \node_modules\react-native-app-settings\android\build\intermediates\res\merged\release

How to resolve Error while updating property 'd' of a view managed by:RNSVGPath InvalidNumber

时光毁灭记忆、已成空白 提交于 2021-02-11 15:27:28
问题 I need to load my sql server data using react-native-chart-kit ,but when I use this code I get this error : Error while updating property 'd' of a view managed by:RNSVGPath null InvalidNumber import React from 'react'; import {Text,View,Dimensions} from 'react-native'; import {LineChart} from "react-native-chart-kit"; export default class Home extends React.Component { constructor(props) { super(props); this.state = { isLoading: true, data: { labels: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu",

Stack components centered above each other in React Native

让人想犯罪 __ 提交于 2021-02-11 15:20:55
问题 I'm trying to place two (or more) components above each others, centered vertically and horizontally in a view that wraps this content (i.e., the height of this outer view should be the max height of the components inside; idem for the width). At first, absolute positioning looked like a good idea to have all the components centered above each other. However then I don't know how to get the outer view to wrap the content. <View style={{ backgroundColor: 'black', alignItems: 'center',

How to require module only if exist. React native

别说谁变了你拦得住时间么 提交于 2021-02-11 15:16:53
问题 Example: let tmp; try { tmp = require('module-name'); } catch(e) { return; } I get error (react native Metro Bundler): error: bundling failed: Error: Unable to resolve module `module-name` from ... How to require "module-name" only if exist? 回答1: That's what works for me: let myPackage; const myPackageToRequire = 'my-package-to-require'; try { myPackage = require.call(null, myPackageToRequire); } catch (e) {} The variable definition const myPackageToRequire = 'my-package-to-require'; is

How can we send props to “withStyles” react js meterial textfield

和自甴很熟 提交于 2021-02-11 15:13:32
问题 I am making a custom textinput with different focus and normal colors, for this i am using withStyles function and i am overriding the control colors. below is the code const CustomTextInput = withStyles({ root: { '& label.Mui-focused': { color: "gray", }, '& .MuiInput-underline:after': { borderBottomColor: "#00ff00", }, '& .MuiInput-underline:before': { borderBottomColor: 'gray', }, }, })(TextField); export default function CustomTextInput(props) { ----- } But in above i have hard coded the

How to find difference between time in moment.js in React Native

三世轮回 提交于 2021-02-11 15:12:52
问题 How can I find difference time in React Native (I'm using moment): Like: let end = endTime; // 10:10:05 let start = startTime; // 10:10:03 moment.utc(moment(end," hh:mm:ss").diff(moment(start," hh:mm:ss"))).format("mm:ss") //expected output: 00:00:02 回答1: You would need to use moment.duration function timeRemaining (start, end) { // get unix seconds const began = moment(start).unix(); const stopped = moment(end).unix(); // find difference between unix seconds const difference = stopped -

How to make a two column grid on react native?

梦想的初衷 提交于 2021-02-11 15:12:33
问题 I am tasked right now with making a screen that gives options in a grid of two columns with multiple cards as the items of a list. (You can see here) I was trying to create a row flexbox, but it ended up simply continuing horizontally forever. I'd like to know what would be a good way to get this effect os two columns expanding downwards. 回答1: You should use FlatList and set numColumns prop to "2" to show FlatList as grid Here is complete code sample import React from "react"; import {