GetStream.io & React Native TypeError: You are publicly sharing your app secret - react-native

I am creating a getstream feed app in react native, and have been trying to debug this error for the past couple hours but with no success. Other's have posted about it on stack overflow but not with using the <StreamApp></StreapApp> component from react-native-activity-feed.
Here is my code
import config from '../../config';
class Feed extends Component {
render(){
return(
<SafeAreaView
style={[{ flex: 1 }, { backgroundColor: '#FFFFFF' }]}
forceInset={{ top: 'always' }}
>
<StreamApp
apiKey={config.stream.app.key}
appId={config.stream.app.id}
token={this.state.token}>
<FlatFeed
feedGroup="timeline"
options={{
limit: 10,
}}
notify
navigation={this.props.navigation}
Activity={(props) => (
<TouchableOpacity
onPress={() => this._onPressActivity(props.activity)}
>
<Activity
{...props}
Footer={
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<LikeButton {...props} />
<ReactionIcon
icon={ReplyIcon}
labelSingle="comment"
labelPlural="comments"
counts={props.activity.reaction_counts}
kind="comment"
/>
</View>
}
/>
</TouchableOpacity>
)}
/>
</StreamApp>
</SafeAreaView>
);
}
}
I am importing the key and id from a config file located in my root directory. I have also tried storing the id and key in a .env file but both efforts result in the same error. The Token I am getting server-side, I don't include the code for retrieving it from AsyncStorage so I don't clutter the post.
Also, here is the exact error:

The problem is how you acquire the token. The error comes up if you store the token in the state, whereas if you import it from the same spot as you import the key and ID the app will load correctly.

Related

Unable to use reanimated-bottom-sheet in React-Native

I install reanimated-bottom-sheet in my react native project but I faced with this error
TypeError: undefined is not an object (evaluating
'InnerNativeModule.installCoreFunctions') ERROR Invariant Violation:
Module AppRegistry is not a registered callable module (calling
runApplication). A frequent cause of the error is that t frequent
cause of the error is that the application entry file path is
incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
this is my code :
import BottomSheet from 'reanimated-bottom-sheet';
const renderContent = () => (
<View
style={{
backgroundColor: 'white',
padding: 16,
height: 450,
}}
>
<Text>Swipe down to close</Text>
</View>
);
const sheetRef = React.useRef(null);
return (
<SafeAreaView>
<View
style={{
flex: 1,
backgroundColor: 'papayawhip',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Button
title="Open Bottom Sheet"
onPress={() => sheetRef.current.snapTo(1)}
/>
</View>
<BottomSheet
ref={sheetRef}
snapPoints={[450, 300, 0]}
borderRadius={10}
renderContent={renderContent}
/>
</SafeAreaView>
);
Please advise what I am doing wrong.
Thanks in advance
Current library that you have used will not work with latest react-native-reanimated version.
You have to use react-native-reanimated version 1.x with that.
Or you can use this updated library https://github.com/gorhom/react-native-bottom-sheet

React Navigation Stack doesn't cover whole screen on desktop

I'm using React Native Web to build a simple Reddit Clone.
I came across this issue while using a StackNavigator from React Navigation.
The stack 'screen' seems to get calculated by the dimensions of the monitor, instead of the content. So when a screen before the currently navigated screen has a larger height than the current screen, the content is still visible 'behind/below' the stack screen.
My homescreen:
<View style={{ flex: 1, backgroundColor: colors.background }}>
<Button style={{ margin: 5 }} action={() => props.navigation.navigate('CreatePost')}><DText>Create post</DText></Button>
<FlatList
data={getPosts}
renderItem={renderPost}
keyExtractor={item => item.id}
/>
</View>
My createpost screen:
<View style={{ flex: 1, backgroundColor: 'red' }}>
<View style={styles.element}>
<TextInput
placeholder={'Title'}
onChangeText={setTitle}
value={getTitle}
/>
<View style={styles.editor}>
<SlateEditor setBody={setBody} />
</View>
<Button action={() => onCreate(getTitle, getBody)}><DText>Post</DText></Button>
</View>
</View>
Here is an example:
I don't want to the user to be able to scroll on the CreatePost screen.
This is fixed by updating #react-navigation/stack to 5.12.6.
See https://github.com/react-navigation/react-navigation/commit/da35085f1e3440f26eea800c892c88aec64d072f

React Native Flatlist image component flickers when data for the flatlist is resorted

I am actually trying to design a chat application, where i rendered all the chats using a flat lists and i have ordered the chats according to their recent message time in descending order, when the order of chat messages changes, the image in chat component gets flickered. Please suggest me a way to prevent this flickering ,in whatsapp and telegram flickering doesn't happen i want to have the smooth ui experience on my chat app also.
I used React Native for the front end.
Here is the Flat list code..
<FlatList
data={state.connections}
refreshing={state.loading}
onRefresh={fetchLatestData}
ListHeaderComponent={<Searchbar
key="editor"
placeholder="Search me..."
value={state.searchValue}
style={{ margin: 15, marginTop: 0 }}
onChangeText={(value) => { fetchConnections(value) }}
/>}
ListHeaderComponentStyle={{ width: width * 1 }}
renderItem={({ item }) => {
let doc_id = getDocId(item.uid, state.userData.uid)
return <ChatCardComponent key={item.uid} data={item} navigation={navigation} userData={state.userData} latestMessageData={state.chattedFriends.get(doc_id)} />
}}
keyExtractor={(item, id) => item.uid}
/>
ChatCardComponentCode is,
I have used react-native-expo-cached-image for Image component
const uri = data.photoUrl;
return (
<View style={styles.container}>
<TouchableOpacity key={data.uid} onPress={() => { props.navigation.navigate('chatWindow', { data: data, userData: userData }) }}>
<View style={styles.chatContainer}>
<CachedImage
style={{ width: 80, height: 80, borderRadius: 60 }}
source={{ uri: uri }}
/>
</View>
</TouchableOpacity>
</View>
Please suggest me fix for this issue.

using react-native-youtube api : youtube videos not rendering

I'm trying to get youtube videos to play in my react-native project. I am using the react-native-youtube module and have enabled YouTubeDataAPIv3 and YouTubeAnalyticsAPI. But I'm getting a blank screen. Sometimes, after a little delay, the screen will resize leaving a smaller white square in the corner and a black background. But still no video.
MY api key does work. I tested this by passing a text-based request through postman. I've also made sure the api is also correctly being passed down to the component. I've tried different videos/videoIds. I've played around with various settings and looked at other examples of working code. My current theory is that this may have something to do with nested views/containers and settings. The videos are in component that is embedded in a parent screen. Maybe a flex:1 is overriding another view? I really don't know. . Has anyone else run into this problem? Any ideas how to fix this?
parent screen:
return (
<SafeAreaView style={{ flex: 1 }}>
<View style={{ flex: 1 }}>
<LeaderBoard />
<CurrentVideos />
</View>
</SafeAreaView>
);
}
video screen:
return (
<ScrollView style={{ flex: 1}>
<View
style={{
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'pink'
}}
>
<YouTube
videoId={'BunklIatIK4'}
play={true}
apiKey={config.API_KEY}
controls={1}
onReady={e => this.setState({ isReady: true })}
onChangeState={e => this.setState({ status: e.state })}
onChangeQuality={e => this.setState({ quality: e.quality })}
onError={e => this.setState({ error: e.error })}
style={{ alignSelf: 'stretch', height: 300 }}
/>
</View>
</ScrollView>
);
Figured it out! The issue was that I hadn't manually moved a copy of the the youtube iframe file from the node modules to the project in Xcode. Now, it's BEAUTIFUL!

Update title and/or buttons in navbar from within component with react-router-native & react-router-navigation

I am using react-router-navigation in my app. Let's say we have a login page where user have to enter his username and this username should appear in navbar as user is typing.
Given that routing is defined elsewhere from the actual component and component does not have callbacks to change route props: is it possible at all to achieve this? Perhaps some smart HOC? Ideas?
Hacks like passing the username all the way around with redux or similar are not the option. To be more specific I wish to be able to override any property specified in Card (right button, title, anything) from within component. Is it possible?
Please find sample code below,
Thanks
class Login extends Component {
render() {
return (
<View
style={{
flex: 1,
flexDirection: 'column',
alignItems: 'center',
}}>
<Text>
Username
</Text>
<TextInput style={{
height: 60,
width: 200,
}}
autoFocus
onChangeText={(value) => {console.log('NAME: ', value)}}/>
</View>
)
}
}
const App = () => (
<NativeRouter>
<Navigation>
<Card path="/"
title="Login"
exact
component={Login}
/>
</Navigation>
</NativeRouter>
)