import { useSelector, useDispatch } from "react-redux";
import {addNum,reduceNum} from '../store/slices/count';
function News() {
    let num = useSelector((state) => {
        return state.countSlice.value;
    });
    let name1 = '';
    useSelector((state) => {
        console.log(state,'初始化')
        name1 = state.useSlice.name;
    })
    let dispatch = useDispatch();
    return (
        <>
            <h1>新的开始</h1>
            <h2>初始值：{num}</h2>
            <h2>{name1}</h2>
            <button onClick={()=>{
                dispatch(addNum())
            }}>++</button>
            <br />
            <button onClick={()=>{
                dispatch(reduceNum())
            }}>--</button>
        </>
    )
}

export default News;