reactjs

Google books api returns missing parameters

ⅰ亾dé卋堺 提交于 2021-02-11 12:46:31
问题 I am making a react app that searches for a book by title and returns the results. It's mostly working fine, but for some titles searched (such as "hello") it can't get the results because the parameters are missing. Specially, the "amount" value is missing, and it can get me e-books that are not for sale even if I add the filter=paid-ebooks param while fetching the api. Using projection=full doesn't help either. For example, when I call the api with https://www.googleapis.com/books/v1

React useSelector not working, what am I doing wrong?

吃可爱长大的小学妹 提交于 2021-02-11 12:46:10
问题 I have a selectors folder with the selector.js file const isRecipeFavorited = state => recipeId => { const recipe = state.find(recipe => recipe.id === recipeId) console.log(`Selector isRecipeFavourtied: ${recipeId}`) return recipe ? recipe.is_fav : false } This is my favicon.js file which calls this useSelector. import React, {useState, useEffect} from 'react' import { FontAwesome } from '@expo/vector-icons' import { View, TouchableOpacity,StyleSheet, Text, Alert } from 'react-native' import

React useSelector not working, what am I doing wrong?

半城伤御伤魂 提交于 2021-02-11 12:45:53
问题 I have a selectors folder with the selector.js file const isRecipeFavorited = state => recipeId => { const recipe = state.find(recipe => recipe.id === recipeId) console.log(`Selector isRecipeFavourtied: ${recipeId}`) return recipe ? recipe.is_fav : false } This is my favicon.js file which calls this useSelector. import React, {useState, useEffect} from 'react' import { FontAwesome } from '@expo/vector-icons' import { View, TouchableOpacity,StyleSheet, Text, Alert } from 'react-native' import

How can I pass state from page to component and back to page?

一笑奈何 提交于 2021-02-11 12:45:52
问题 Is there a way without using Redux with which I can from my home.js page (I'm using hooks not classes) set/use a state, pass it to my component MyComponent.js and once a div is clicked inside this component update the state (so for the home.js page as well)? In home.js I have something like: export default function Page({ session, items }) { const [selectedTab, setSelectedTab] = useState('main') const handleSelect = (e) => { setSelectedTab(e); } ... // then I return some react-bootstrap tabs,

different between hoc + redux and redux

微笑、不失礼 提交于 2021-02-11 12:44:54
问题 I'm trying to wrap redux into a react hoc like this const WithUser = WrappedComponent => { return class ComponentWithUser extends Component { render() { return <WrappedComponent {...this.props}>{this.props.children}</WrappedComponent> } } } const mapStateToProps = state => { return { user: state.user, } } const composeWithUser = compose(connect(mapStateToProps, null), WithUser) export default composeWithUser If I going to write code in this way, is there any difference from directly connect

What is the authentication/authorization scenario for web app that calls API without signed in user in azure AD?

久未见 提交于 2021-02-11 12:41:19
问题 I have web app written in react which is Single Page Application. Then I have back end API written in .NET core 3.1. As I mentioned earlier I have web app written in react so this react web app has to call one more API to read some configs. This third application is also a API application written in .NET core 3.1. As soon as web app spins up, it will call this third APP and read configs like API URL of second application and other azure related details. Now this third API app should be

React State value not updated in Arrow functional component

大憨熊 提交于 2021-02-11 12:41:07
问题 React state value not updated in the console but it is updated in the view. This is my entire code import React, { useEffect, useState } from 'react'; const Add = (props) => { console.log("a = ", props.a) console.log("b = ", props.b) const c = props.a+props.b; return ( <div> <p><b>{props.a} + {props.b} = <span style={{'color': 'green'}}>{c}</span></b></p> </div> ) } // export default React.memo(Add); const AddMemo = React.memo(Add); const MemoDemo = (props) => { const [a, setA] = useState(10)

React State value not updated in Arrow functional component

最后都变了- 提交于 2021-02-11 12:40:57
问题 React state value not updated in the console but it is updated in the view. This is my entire code import React, { useEffect, useState } from 'react'; const Add = (props) => { console.log("a = ", props.a) console.log("b = ", props.b) const c = props.a+props.b; return ( <div> <p><b>{props.a} + {props.b} = <span style={{'color': 'green'}}>{c}</span></b></p> </div> ) } // export default React.memo(Add); const AddMemo = React.memo(Add); const MemoDemo = (props) => { const [a, setA] = useState(10)

How to access HTTP Cookie in Node.JS - JWT

只谈情不闲聊 提交于 2021-02-11 12:40:51
问题 This might seem like a redundant question, but please hear me out first: I'm working with a React Frontend and a Node Backend. I'm using JWT to deal with user authentication. Right now, I'm having trouble actually working with the JWT and performing the authentication. Here's where I'm stuck: ~ I try setting the token as an http cookie in my backend. If i work with postman, I see the token being set. However, when I use req.cookies.token to try and receive the token cookie to perform

React State is not updated with socket.io

半腔热情 提交于 2021-02-11 12:40:29
问题 When page loaded first time, I need to get all information, that is why I am calling a fetch request and set results into State [singleCall function doing that work] Along with that, I am connecting websocket using socket.io and listening to two events (odds_insert_one_two, odds_update_one_two), When I got notify event, I have to check with previous state and modify some content and update the state without calling again fetch request. But that previous state is still [] (Initial). How to get