Commit d025594e authored by Thor-Herman's avatar Thor-Herman
Browse files

Refactor MoviePage for react-navigation #12 #11

parent 2bbaea73
import { RouteProp } from '@react-navigation/native';
import { StackNavigationProp } from '@react-navigation/stack';
import { Image, Item } from 'native-base';
import React from 'react';
import { View, Text } from 'react-native';
import { useSelector } from 'react-redux';
import { useParams } from 'react-router-native';
import { StackParamList } from '../components/App';
import { RootState } from '../reducers';
import { Movie } from '../types/movies';
interface MovieParams {
movieId: string
}
type MovieScreenRouteProp = RouteProp<StackParamList, 'Movie'>;
type MovieScreenNavigationProp = StackNavigationProp<StackParamList, 'Movie'>;
type Props = {
navigation: MovieScreenNavigationProp;
route: MovieScreenRouteProp;
};
const MoviePage = () => {
const { movieId } = useParams<MovieParams>();
const movie: Movie = useSelector((state: RootState) => state.movies.byId[+movieId]);
console.log(movie);
const MoviePage = ({navigation, route}: Props) => {
const movie: Movie = useSelector((state: RootState) => state.movies.byId[route.params.id]);
return (
<View>
<Text>{movie.id}</Text>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment