1

I am working on reactJS and redux-saga project, I have a problem using the default export, I have a file like this :

import TYPE_CONTRAT_UPDATE from "./actionsTypes";
import { createAction } from "../../../../../../redux/Utilities";

const updateTypeContrat = (idContrat, data, success, error) =>
    createAction(TYPE_CONTRAT_UPDATE.PUT_CALL, { idContrat, data, success, 
error });
const updateConformiteContrat = (idContrat, data, success, error) => 
    createAction(CONFORMITE_PUT.PUT_CALL, { idContrat, data, success, error 
});

export default updateTypeContrat;
export default updateConformiteContrat;

But as you know I can not have two defaults in one file, is there any solution to this ? how can I make a default export to both ?

Any help would be much appreciated.

TaouBen
  • 1,165
  • 1
  • 15
  • 41

2 Answers2

3

There can only be one default export in a file. You can have other exports along with a default one like this.

import TYPE_CONTRAT_UPDATE from "./actionsTypes";
import { createAction } from "../../../../../../redux/Utilities";

const updateTypeContrat = (idContrat, data, success, error) =>
    createAction(TYPE_CONTRAT_UPDATE.PUT_CALL, { idContrat, data, success, 
error });
const updateConformiteContrat = (idContrat, data, success, error) => 
    createAction(CONFORMITE_PUT.PUT_CALL, { idContrat, data, success, error 
});

export default updateTypeContrat;
export {
  updateConformiteContrat
};

and import like this -

import updateTypeContrat from './<path>'
import { updateConformiteContrat } from './<path>'

Hope this helps !

Hemant Parashar
  • 3,684
  • 2
  • 16
  • 23
2

export default { updateTypeContrat, updateConformiteContrat }

import { updateTypeContrat, updateConformiteContrat } from './your-folder'