jeudi 6 décembre 2018

Export default react-native component

For my solution I want users to get all components from my library.

Example: import Checkbox from 'MyLibrary';

But for native, I'm don't want to make all the components my self. At least, not now. And that is why I want them to reference my library, so when I do change/write the component, it will automaticly update at their end.

For example, a checkbox. There is a default react-native checkbox (https://facebook.github.io/react-native/docs/checkbox)

I would like to export this default component within my component.

I tried things like:

export { Checkbox as default } from 'react-native';

and

import { Checkbox } from 'react-native';

export default Checkbox;

and

import React from 'react';
import { Checkbox as ReactCheckbox } from 'react-native';

const Checkbox = (...props) => <ReactCheckbox {...props} />;

export default Checkbox;

But that didn't work. Any suggestions?




Aucun commentaire:

Enregistrer un commentaire