Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,14 @@ const SimpleTemplate = () => {

</details>

## react-xarrows V3
react-xarrows v3 on it's way, see [discucssion](https://github.com/Eliav2/react-xarrows/discussions/96)

## Usage

react-xarrow v2.0 released! no need to trigger render on parents anymore!
react-xarrows will smartly trigger updates on relevant elements! use `Xwrapper` and `useXarrow` hook to achieve
selective rendering!

please note that v2.0.0 is not working using react [StrictMode](https://reactjs.org/docs/strict-mode.html). to fix
update to v2.0.1.

##### breaking changes

V2.0 introduced some breaking changes, mainly related to properties naming. see [CHANGELOG.md](./CHANGELOG.md) for
details.

#### useXarrow

```jsx
Expand Down Expand Up @@ -709,3 +703,13 @@ details {
margin: 1em 0;
}
</style>

## Troubleshooting

### 1. TypeError: \_c.getTotalLength is not a function

If you receive this error in your tests suits while using react-testing-library, you can import mockReactXarrow from 'react-xarrow/testing' like this:

`import { mockReactXarrow } from 'react-xarrow/testing'`

and use `mockReactXarrow()` function in your tests setup to avoid this error.
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './types';
export * from './constants';
export { default as Xwrapper } from './Xwrapper';
export { default as useXarrow } from './useXarrow';
export { mockReactXarrow } from './testing/setup';
12 changes: 12 additions & 0 deletions src/testing/setup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const mockReactXarrow = () =>
jest.mock('react-xarrows', () => {
return {
__esModule: true,
default: () => <span />,
useXarrow: () => null,
};
});

export { mockReactXarrow };