Skip to content

Instantly share code, notes, and snippets.

@ravewebdev
Last active July 14, 2020 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravewebdev/1803f8344b70a9251feba8532b496ef5 to your computer and use it in GitHub Desktop.
Save ravewebdev/1803f8344b70a9251feba8532b496ef5 to your computer and use it in GitHub Desktop.
2.1.2. Use State and Effect hooks to track attribute changes
const FrontendTracker = ( props ) => {
// Code from 2.1.1. here...
const [ attributes, setAttributes ] = useState( {
block_id: 0,
} );
useEffect( () => {
setAttributes( {
...dataAttributes,
} );
}, [] );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment