Skip to content

Commit 06b09ad

Browse files
author
Ives van Hoorne
committed
Add onFileChange
1 parent bd985ff commit 06b09ad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/react-sandpack/src/components/SandpackProvider/SandpackProvider.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ export interface Props {
2323
width?: number | string;
2424
height?: number | string;
2525
bundlerURL?: string;
26-
skipEval: boolean;
26+
skipEval?: boolean;
2727
template?:
2828
| 'create-react-app'
2929
| 'create-react-app-typescript'
3030
| 'parcel'
3131
| 'vue-cli'
3232
| 'angular-cli'
3333
| 'preact-cli';
34+
35+
onFileChange?: (files: IFiles) => void;
3436
}
3537

3638
export default class SandpackProvider extends React.PureComponent<
@@ -133,6 +135,9 @@ export default class SandpackProvider extends React.PureComponent<
133135
updateFiles = (files: IFiles) => {
134136
this.setState({ files });
135137

138+
if (this.props.onFileChange) {
139+
this.props.onFileChange(files);
140+
}
136141
if (this.manager) {
137142
this.manager.updatePreview({ files, template: this.props.template });
138143
}

0 commit comments

Comments
 (0)