'Using functions from imported modules in another file

Say I have file1.js and file2.js...

file1.js:

import React from 'react';

const test = ( {prop} ) => {
    function test1() {
        prop('1');
    }
    function test2() {
        prop('2');
    }
    function test3() {
        prop('3');
    }


    return (
        <div>
        ...          
        </div>
    )
}

export default test;

file2.js:

import test from './file1.js'

...

return (
   <button onClick={...}>
   </button>
)

...

How do I call any of the test1/2/3 functions with the onClick attribute in file2.js? Is that even possible? I am new to JS, so any and all feedback would be greatly appreciated!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source