Skip to content

Commit

Permalink
Fix the jslint warning (or infinate loop error when fixed) from useSe…
Browse files Browse the repository at this point in the history
…lect usage (#651)
  • Loading branch information
pbking authored May 23, 2024
1 parent 16f26cf commit 3b69810
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/editor-sidebar/create-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,24 @@ import ScreenHeader from './screen-header';
export const CreateThemePanel = ( { createType } ) => {
const { createErrorNotice } = useDispatch( noticesStore );

const subfolder = useSelect( ( select ) => {
const stylesheet = select( 'core' ).getCurrentTheme().stylesheet;
if ( stylesheet.lastIndexOf( '/' ) > 1 ) {
return stylesheet.substring( 0, stylesheet.lastIndexOf( '/' ) );
}
return '';
}, [] );

const [ theme, setTheme ] = useState( {
name: '',
description: '',
uri: '',
author: '',
author_uri: '',
tags_custom: '',
subfolder: '',
subfolder,
} );

useSelect( ( select ) => {
const themeData = select( 'core' ).getCurrentTheme();
setTheme( {
...theme,
subfolder:
themeData.stylesheet.lastIndexOf( '/' ) > 1
? themeData.stylesheet.substring(
0,
themeData.stylesheet.lastIndexOf( '/' )
)
: '',
} );
}, [] );

const cloneTheme = () => {
if ( createType === 'createClone' ) {
handleCloneClick();
Expand Down

0 comments on commit 3b69810

Please sign in to comment.