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

prevState in gutenberg #7302

Closed
sylvaincordiere opened this issue Jun 13, 2018 · 2 comments
Closed

prevState in gutenberg #7302

sylvaincordiere opened this issue Jun 13, 2018 · 2 comments
Labels
[Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@sylvaincordiere
Copy link

sylvaincordiere commented Jun 13, 2018

I have an attribute checked which is a boolean type
like this

checked:{
   		 type:   'boolean',
   		 default: false,
   	}

Is it possible to use prevState with it ?


					      setAttributes((prevState, checked) => ({
						  checked: !prevState.checked
						}));
@mitogh
Copy link
Member

mitogh commented Jun 14, 2018

I think you can use componentDidUpdate(prevProps, prevState, snapshot) in your component where you have to the prevProps and the attributes are props injected into the component. @sylvaincordiere .

Unless you want to access the value on initial loading.

@danielbachhuber danielbachhuber added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Jun 14, 2018
@mcsf
Copy link
Contributor

mcsf commented Jul 19, 2018

Closing as duplicate of #5596.

@mcsf mcsf closed this as completed Jul 19, 2018
@designsimply designsimply added the [Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed label Jul 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] Duplicate Used to indicate that a current issue matches an existing one and can be closed [Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

5 participants