Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not sync redux State #557

Open
sailei1 opened this issue Sep 6, 2023 · 1 comment
Open

can not sync redux State #557

sailei1 opened this issue Sep 6, 2023 · 1 comment

Comments

@sailei1
Copy link

sailei1 commented Sep 6, 2023

Describe the bug
截屏2023-09-06 下午12 20 50


export  const  CustomFormFrame=(props:any)=> {
    const [enable,setEnable]=useState(true)


    const formData = useSelector((state:any) => {
        return  state.formData});
    const dispatch = useDispatch();

    const updateVal=(k:string,v:any)=>{
        let data=Object.assign({},formData);
        data[`${k}`]=v;
        dispatch({ type: 'CHANGE_DATA', payload: {formData:data} });
    }


    const test=()=>{
           debugger
           console.log('test ',formData)
          if(formData.select){
              // return <CustomFormSelect k={'select'} v={'running'} updateVal={updateVal}/>
              return<div>44444</div>
          }else{
              return <div>12312</div>
          }
    }






    return (
        <div className="App">
            <Editor resolver={{ CustomForm,Button,CustomFormInput,CustomFormSelect }} enabled={enable} >
                <Frame>
                    <Element is={CustomForm} canvas>


                        <CustomFormInput k={'input'} v={111} updateVal={updateVal}/>
                        <hr/>
                        <div>{JSON.stringify(formData)}</div>
                        {/*<CustomFormSelect k={'select'} v={'running'} updateVal={updateVal}/>*/}
                        {test()}

                        <h1>Hello CodeSandbox</h1>
                        <Button />
                        <h2>Start editing to see some magic happen!</h2>
                    </Element>
                </Frame>
                {/*<Layers />*/}
            </Editor>
            <div>{JSON.stringify(formData)}</div>
            {test()}

        </div>
    );
}

Your environment

Software Version(s)
"@craftjs/core": "^0.2.0-beta.12",
 "react": "^18.2.0",
"react-dnd": "^16.0.1",
"react-dnd-html5-backend": "^16.0.1",
"react-dom": "^18.2.0",
"react-redux": "^8.1.2",
"react-scripts": "5.0.1",
"redux": "^4.2.1",
"typescript": "^4.7.4",

node:18.3.0
npm 8.11.0

mac os

@sailei1
Copy link
Author

sailei1 commented Sep 11, 2023

@prevwong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant