我正在React Native中创建一个getstream feed应用程序,并且在过去的几个小时里一直在尝试调试此错误,但是没有成功。其他人则在堆栈溢出时发布了相关信息,但没有使用<StreamApp></StreapApp>
中的react-native-activity-feed
组件。
这是我的代码
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>
);
}
}
我正在从位于我的根目录中的配置文件中导入密钥和ID。我也尝试过将ID和密钥存储在.env文件中,但是两种方法都会导致相同的错误。我正在服务器端获得令牌,我不包含用于从AsyncStorage检索令牌的代码,因此我不会使帖子混乱。
答案 0 :(得分:0)
问题在于您如何获取令牌。如果将令牌存储在状态中,则会出现错误,而如果在导入密钥和ID的位置从同一位置导入令牌,则应用程序将正确加载。