Within my React Native app designed for Android, I've integrated a component that relies on the Redux
library.
Referencing "Hemant" from this thread, it was advised to pass the action as an imported prop
into the component. However, I'm encountering an error while attempting to correctly type the action:
Binding element 'string' implicitly has an 'any' type
, leaving me puzzled about its cause.
Below is the snippet of code in question:
imports ...
import {reduxAction} from '../../../store/searchBar/actions';
type Props = {
reduxAction: ({value: string}) => void;
};
const SearchBar: React.FC<Props> = ({reduxAction}) => {
// invoking the action method
const sendNamesToReduxStore = (names: string) => {
// ... some other logic
// calling the action method
reduxAction({value: names});
};
The issue arises when calling the action method with names
declared as type string
. Consequently, I ensured to declare it as string
within Props
as well. I deemed this as correct initially. It's worth noting that changing
reduxAction: ({value: any}) => void;
results in the same error relating to any
: Binding element 'any' implicitly has an 'any' type
.
Could someone clarify where I might be making a misstep in this scenario?