Exporting A Default & Declaring Anon Function All In One
Here's an example of something I want to do and currently throws an error. I'm not sure I understand why, but it's not syntactically correct to export, assign default, and assign a
Solution 1:
You can do that for named exports if you want, but not for default ones.
Your alternatives are:
Don't declare a variable. After all, you just want to export a single value:
exportdefault(props)=> ( … );
Declare the variable and export it in two separate declarations:
letCheckbox = (props) => ( … ); exportdefaultCheckbox;
If you need to bind to the variable because you want to (re)assign to it (as
let
suggests), useexport {Checkboxasdefault};
Use a proper function declaration (which binds the local variable as well):
exportdefaultfunctionCheckbox(props) { return … }
If you don't need that, you can also export an unnamed function declaration.
Post a Comment for "Exporting A Default & Declaring Anon Function All In One"