I wanted to export a function and use it in the ReactJS component in my Javascript code, but when I tried to export the latter, the system showed me an error at the level of the export instruction, saying:
Declaration or statement expected. ts(1128)
would you please help me fix this error?
function close_sidebar() {
$("div#sidebar").css("display", "none");
$("div#rest").css("margin-left", "4px");
$("div#rest").css("width", "100%");
$("li#opensidebar").css("display", "block");
}
export close_sidebar;
CodePudding user response:
Move the export statement to the same line as the function definition:
export function close_sidebar() {
$("div#sidebar").css("display", "none");
$("div#rest").css("margin-left", "4px");
$("div#rest").css("width", "100%");
$("li#opensidebar").css("display", "block");
}