Open ohol-vitaliy opened 3 years ago
components are technically functions, so you can do something like
---
defines-react-components: true
---
Definition:
```jsx:component:myRand
return Math.random()
Usage:
<div>A random number is {myRand()}</div>
Or, if you want to define more complex functions with multiple arguments, you can do something like
````md
---
defines-react-components: true
---
Definition:
```jsx:component:utils
function add(a, b) {
return a+b;
}
return { add };
Usage:
const {add} = utils();
<div>The sum of 1 and 2 is {add(1,2)}</div>
customJS plugin also works with jsx.
It would be great to have a way to reuse code (functions) in multiple components