i want be able to enable or disable this action:
This works perfect in react-native without redux, but when i add redux this action not works and come back again like the gif
I'm following this links but in this cases, this works with Navigator but i'm not using this prop. i'm using NavigationExperimental.
Thanks for help.
To disable gestures in NavigationExperimental CardStack, use it like this:
render () {
<CardStack
navigationState={navigationState}
... other properties
enableGestures={false}
/>
}
For more info (for RN 0.40) see sources NavigationCardStack.js
Related
I am trying to use 'react-native-popup-dialog' to include pop ups in my react-native app.
I have a component 'HeaderView' which I am including in all other components for example 'Home' as
<HeaderView/>.
For 'HeaderView' component I have set flex to 0.5 and there is a button whose onpress event I want to capture in 'Home' component.
onPress={() => {
this.popupDialog.show();
}}
And PopupDialog exists in 'Home' Component.
If I include PopupDialog in HeaderView, I get popup only in 0.5 (flex) part of screen.
Is there any way to achieve this or will I have to discard my HeaderView component and add its logic in all components?
You can do that in so many ways.
As one of those you can use this:
Add some listener in the root of your app (e.g: App.js) and render popup dialog there, and finally show modal with emitting the listener. (react-native-event-listeners)
Another simple way is using ContextApi
But you should know that the best way is rendering your main modal in root and call the functionalities about that with some tools like the above examples or even something like redux.
I'm using code like this it is not working for me
componentWillRecieveProps(nextProps,nextState){
if(nextProps.navigation.state != this.state){
//here calling api
}
}
I think the question should be more elaborative to help to solve your issue. Based on your questions, you may be asking for either -
How to reload page if data changes
How to reload page if navigation state changes
How to reload page if data changes
In this case, you no need to add 'componentWillRecieveProps'. You can simply check for a value in render method like this
{data.items.length && <ItemLIstCustomComponent />}
or
{data.items.length ? <ItemLIstCustomComponent /> : <EmptyMessageComponent />}
You can look into conditional rendering in react-native.
If the re-render is not happening still? Then your way of updating state/data is not correct. Make sure you make copy of object and update the existing one.
To understand this, read about mutable objects and react shallow-check for re-rendering. Or may be this will help
How to reload page if navigation state changes
I don't think it is good practice to call another API or do any state change related thing in componentWillRecieveProps. You can create a new Screen on which you navigate and call API in componentDidMount.
You can try React navigation if you are not using any navigation library.
I am trying to use expo google siginin. However I cannot find how to render the signin button itself. How do I get the actual button to render in my view?
I am using this doc: https://docs.expo.io/versions/v36.0.0/sdk/google/
Expo doesn't provide the button for you. You can use react-native-elements. They have a SocialIcon component, which does exactly what you need. Just give it type={"google"} as a prop.
<SocialIcon
title={"Sign In With Google"}
button={true}
type={"google"}
/>
More about the component here.
I'm using the react-instantsearch module on a React Native app. I'm using it as a controlled component, passing in a searchState like so:
<InstantSearch
appId='something'
apiKey='somethingElse'
indexName='index'
searchState={this.props.algoliaSearchState}
>
When I change the category (hierarchicalMenu) or location (aroundLatLng), this works fine, but when I change the query it has no effect on the hits that I get.
I can see that the query is being passed in (both by logging, and in react-native devtools:
Any ideas what could be going wrong here?
For a refinement to be applied, it needs to be present inside the search state and have a corresponding widget mounted.
For hierarchicalMenu it's HierarchicalMenu, for aroundLatLng it's Configure and for query it's SearchBox.
If you don't want any rendering for a widget just create a VirtualWidget. But for its refinement to be applied, it should be mounted.
I'm building an app in React native, and basically, I need a modal(which will have the same content every time) to be available globally (in all components of app), so that I can be able to open it from anywhere in my app.
Obviously copy/pasting the same modal in all the components is not a good solution
Right now I'm having tons of trouble implementing it, so I would like to know what would be the best way to accomplish something like that
Use a Navigator and place your modal below it. Make it visible only when the state changes. The state can be changed from each component inside the Navigator via props.navigator.
You can see the full code with explanation here http://browniefed.com/blog/react-native-easy-overlay-modal-with-navigator/