-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added navigation connecting redux between product page and product de…
…tails
- Loading branch information
1 parent
8e94d13
commit 63db4a3
Showing
8 changed files
with
228 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import React from 'react'; | ||
import { StatusBar, View } from 'react-native'; | ||
import Navigation from './src/navigation/Navigation'; | ||
import { store } from './src/redux/store'; | ||
import { Provider } from 'react-redux'; | ||
|
||
export default function App() { | ||
return ( | ||
<View style={{ flex: 1 }}> | ||
<Navigation /> | ||
<StatusBar /> | ||
</View> | ||
<Provider store={store}> | ||
<View style={{ flex: 1 }}> | ||
<Navigation /> | ||
<StatusBar /> | ||
</View> | ||
</Provider> | ||
); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
import products from '../../data/products'; | ||
|
||
const initialState = { | ||
value: 0, | ||
items: products, | ||
selectedProduct: null, | ||
}; | ||
|
||
export const itemSlice = createSlice({ | ||
name: 'items', | ||
initialState, | ||
reducers: { | ||
setSelectedProduct: (state, action) => { | ||
const id = action.payload; | ||
const itemExists = state.items.find((item) => item.id === id); | ||
state.selectedProduct = itemExists; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { setSelectedProduct } = itemSlice.actions; | ||
|
||
export default itemSlice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { configureStore } from '@reduxjs/toolkit'; | ||
import ItemSlice from './slice/ItemSlice'; | ||
|
||
export const store = configureStore({ | ||
reducer: { | ||
products: ItemSlice, | ||
}, | ||
}); |
Oops, something went wrong.