|
1 | 1 | # Changelog |
2 | 2 |
|
| 3 | +## 2.5.0 |
| 4 | + |
| 5 | +- Fix `default` case for the switch statement in `VM`. |
| 6 | +- Add a VM feature, `enableComponentSrcDataKey`, which adds the `data-component` attribute specifying the path of the comonent responsible for rendering the DOM element. |
| 7 | +- Add support for VM.require when using redirectMap. |
| 8 | +- Fixes an issue with VM.require not retaining context in migration to initGlobalFunctions. |
| 9 | +- Add `onLink` and `onImage` to Markdown component. It allows to display links and images differently. |
| 10 | +- Expose all VM functions into the state directly, it simplifies VM readability and implementation. |
| 11 | +- Expose certain native objects directly into the state. It should improve access to the functions. |
| 12 | +- Update the way events and errors are passed to the functions. |
| 13 | + - For events, expose `preventDefault()` and `stopPropagation()` functions. |
| 14 | + NOTE: Previously, all React's `SyntheticEvent`s were getting `preventDefault()` called by default. |
| 15 | + - For errors, expose `message`, `name` and `type`. |
| 16 | +- Fix `vm.depth` not being initialized. |
| 17 | +- Introduce `useMemo` hook. Similar to the React hook, it calculates a value and memoizes it, only recalculating when one of its dependencies changes. |
| 18 | + |
| 19 | +```jsx |
| 20 | +const data = [ |
| 21 | + //...some large array |
| 22 | +]; |
| 23 | + |
| 24 | +const filteredData = useMemo(() => { |
| 25 | + console.log("Filtering data"); |
| 26 | + return data.filter(/* some filtering criteria */); |
| 27 | +}, [data]); |
| 28 | + |
| 29 | +return ( |
| 30 | + <div> |
| 31 | + {filteredData.map(item => ( |
| 32 | + <div key={item.id}>{item.name}</div> |
| 33 | + ))} |
| 34 | + </div> |
| 35 | +); |
| 36 | +``` |
| 37 | + |
| 38 | +- Introduce `useCallback` hook. Similarly to the React hook, it memoizes a callback function and returns that memoized version unless one of its dependencies changes. |
| 39 | + ```jsx |
| 40 | + const incrementCounter = useCallback(() => { |
| 41 | + setCounter(counter + 1); |
| 42 | +}, [counter]); |
| 43 | + |
| 44 | +return ( |
| 45 | + <div> |
| 46 | + Counter = {counter} |
| 47 | + <div> |
| 48 | + <button onClick={incrementCounter}>Increment</button> |
| 49 | + </div> |
| 50 | + </div> |
| 51 | +); |
| 52 | +``` |
| 53 | + |
3 | 54 | ## 2.4.2 |
4 | 55 |
|
5 | 56 | - Add missing code changes (`cacheOptions` and `lodash`) from 2.4.0. |
|
0 commit comments