How to create helper file full of functions in react native?

后端 未结 6 743
悲哀的现实
悲哀的现实 2020-12-04 06:48

Though there is a similar question I am failing to create a file with multiple functions. Not sure if the method is already outdated or not as RN is evolving very fast. How

6条回答
  •  醉梦人生
    2020-12-04 07:29

    i prefer to create folder his name is Utils and inside create page index that contain what that think you helper by

    const findByAttr = (component,attr) => {
        const wrapper=component.find(`[data-test='${attr}']`);
        return wrapper;
    }
    
    const FUNCTION_NAME = (component,attr) => {
        const wrapper=component.find(`[data-test='${attr}']`);
        return wrapper;
    }
    
    export {findByAttr, FUNCTION_NAME}
    

    When you need to use this it should be imported as use "{}" because you did not use the default keyword look

     import {FUNCTION_NAME,findByAttr} from'.whare file is store/utils/index'
    

提交回复
热议问题