不知道为什么连我都修改了草稿,immer没有给我提供新的状态,而是修改了内容的旧状态实例。
import CartItem from "../../models/cart-item";
import * as actions from "../actions/actionTypes";
import produce from "immer"
const initialState = [];
const reducer = (state=initialState, action) => {
switch (action.type) {
case actions.ADD_TO_CART:
const {id, title, price} = action.product;
const itemIndexInCart = state.findIndex(item => item.id === id);
const nextState = produce(state, draftState => {
if (itemIndexInCart === -1) {
draftState.push(new CartItem(id, 1, price, title, price));
} else {
draftState[itemIndexInCart]['quantity']++;
draftState[itemIndexInCart]['sum'] += price;
}
});
console.log(state === nextState);
return nextState;
default:
return state; …
Run Code Online (Sandbox Code Playgroud) 我使用FirebaseUI FirebaseListAdapter.加载数据需要一些时间,我想显示一个旋转的圆圈.我可以通过在populateView中将视图可见性设置为不可见来忽略进度条,但如果没有要填充的视图则它不起作用.怎么办呢?
我想创建一个水平 ScrollView,但我遇到了一些问题。ScrollView 占用了屏幕的所有剩余空间,但我想要的是 ScrollView 仅占用最大子项的高度。我怎样才能做到这一点?
我尝试在样式上设置固定高度,但这不起作用。有什么帮助吗?
<ScrollView horizontal showsHorizontalScrollIndicator={false} style={styles.guessList}>
{guessList.map((guess, index) => (
<NumberContainer style={styles.guessItem} key={guess}>#{guessList.length - index} {guess}</NumberContainer>
))}
Run Code Online (Sandbox Code Playgroud)
const styles= StyleSheet.create({
guessList: {
height: 70
},
guessItem: {
marginRight: 5
}
Run Code Online (Sandbox Code Playgroud)
});
reactjs ×2
android ×1
firebase ×1
firebaseui ×1
immer.js ×1
javascript ×1
react-native ×1
redux ×1