@@ -93,6 +93,7 @@ function classNames(...classes: any) {
93
93
export default function Example ( ) {
94
94
const [ code , setCode ] = useState ( '' ) ;
95
95
const [ outputDisplay , setOutputDisplay ] = useState ( '' ) ;
96
+ const [ lastExampleId , setLastExampleId ] = useState ( '' ) ;
96
97
const [ selectedLanguage , setSelectedLanguage ] = useState ( languagesDropdown [ 0 ] ) ;
97
98
const [ selectedFormat , setSelectedFormat ] = useState ( formats [ 0 ] ) ;
98
99
const [ commentsEnabled , setCommentsEnabled ] = useState ( true ) ;
@@ -126,7 +127,8 @@ export default function Example() {
126
127
} ;
127
128
128
129
const onGenerateExample = ( ) => {
129
- const randomExample = EXAMPLES [ Math . floor ( Math . random ( ) * EXAMPLES . length ) ] ;
130
+ const filteredExamples = EXAMPLES . filter ( ( example ) => example . id !== lastExampleId ) ;
131
+ const randomExample = filteredExamples [ Math . floor ( Math . random ( ) * filteredExamples . length ) ] ;
130
132
const foundLanguage = languagesDropdown . find (
131
133
( languageOption ) => languageOption . id === randomExample . languageId ,
132
134
) ;
@@ -138,6 +140,7 @@ export default function Example() {
138
140
setSelectedLanguage ( foundLanguage ) ;
139
141
setSelectedFormat ( foundFormat ) ;
140
142
setCode ( randomExample . code ) ;
143
+ setLastExampleId ( randomExample . id ) ;
141
144
} ;
142
145
143
146
const onClickGenerate = async ( ) => {
0 commit comments