Commit 269bed8e authored by Thor-Herman's avatar Thor-Herman
Browse files

Add handleChange and onSubmit to searchbar #9

parent 923c93be
import { Container, Icon, Input, Item, View } from 'native-base';
import React from 'react';
import React, { Props, useEffect } from 'react';
import { NativeSyntheticEvent, TextInputChangeEventData, TextInputSubmitEditingEventData } from 'react-native';
import { useDispatch, useSelector } from 'react-redux';
import { Link } from 'react-router-native';
import { searchMovieTitles, searchMovies } from '../actions';
import { RootState } from '../reducers';
const SearchBar = () => {
const dispatch = useDispatch();
const handleChange = (e: NativeSyntheticEvent<TextInputChangeEventData>): void => {
const term = e.nativeEvent.text;
dispatch(searchMovieTitles(term)); // Update the search term
}
const onSubmit = (e: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => {
e.preventDefault();
dispatch(searchMovies(true)); // Perform search with current searchTerm
}
return (
<>
<Item style={{flex: 4}}>
<Icon name='search' />
<Input placeholder='Search for a movie...' />
<Input placeholder='Search for a movie...' onSubmitEditing={onSubmit} onChange={handleChange} />
</Item>
</>
);
......
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