我是React Native(包括Redux)编程的“高级初学者”。现在,我正在努力更新商店(因此需要重新渲染UI)。据我所知,我确实遵循了所需的核心规则:
任何对我的提示都会引起高度赞赏:
APP.JS
Let's perform Google search with python
ACTION.JS
from selenium import webdriver
url = 'https://www1.swatchseries.to/freecale.html?r=qepyJmjdCI6Ilo2SWFPdlk51dDBoMSmtxeHFnWXBbVOEJrcVdVMXhPT2t0bUZEZzNtNEd5ZVhCNHYrWnZkT0NZYzdZaWpmZlB0alEiLCJpdiI6IjFmYTdhMzZjYjJhODc1ZmIxODQ4MzVhZDc2N2MyYjNiIiwicyI6Ijc2NTZiMDg0MDFhNmQ1NjYifQ=='
driver = webdriver.Chrome('drivers/chromedriver.exe')
driver.maximize_window()
driver.get(url)
elements = driver.find_elements_by_xpath('/html/body/div[2]/div[2]/div/div[2]/div/div/div/div/div/div/div/div[2]/a')
for element in elements:
print(element.get_attribute('href'))
REDUCER.JS
http://www1.swatchseries.to/
Process finished with exit code 0
COMPONENT.JS
import React from "react";
import { createStore, combineReducers } from "redux";
import { Provider } from "react-redux";
import Navigator from "./navigation/navigator";
import productReducer from "./store/reducers/products";
const rootReducer = combineReducers({
product: productReducer,
});
const store = createStore(rootReducer);
console.log("Erstellter Store: ", store.getState());
export default function App() {
return (
<Provider store={store}>
<Navigator />
</Provider>
);
}
答案 0 :(得分:2)
我认为您的reducer应该返回以下对象:
return {...state, allProducts: [...newProducts] };
您当前正在使用名为newProducts
的新属性更新状态,而应将其命名为allProducts
。