I have 3 components: Layout App Products
My Layout has this form:
<form className='d-flex'>
<input
name='search'
className='form-control mr-2 shadow-none'
type='search'
placeholder='Search'
value={search}
onChange={(e) => setSearch(e.target.value)}
/>
<button className='btn btn-outline-secondary' type='submit'>
<SearchIcon />
</button>
</form>
I passed search and setSearch through props.
In my App has this logic:
const [search, setSearch] = useState('');
<Layout search={search} setSearch={setSearch}>
<Route exact path='/' search={search} component={Products} />
</Layout>
I pulled the search result from the Layout and created a state in the App and then trying to pass to the Products component.
In the product when I try to console the search result I see only an undefined result