Skip to content

Commit fc22297

Browse files
docs: improve grammar on animated-elements.mdx (#2249)
1 parent 931e427 commit fc22297

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

docs/app/routes/docs.concepts.animated-elements.mdx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ export const meta = formatFrontmatterToRemixMeta(frontmatter)
1919

2020
## What are they?
2121

22-
The basis of `react-spring` depends on two things, `SpringValues` & `animated` components. Lets explore the latter.
22+
The basis of `react-spring` depends on two things, `SpringValues` & `animated` components. Let's explore the latter.
2323
An `animated` component receives `SpringValues` through the `style` prop and updates the element without causing a
24-
react render. It works because it is a [Higher-Order component](https://reactjs.org/docs/higher-order-components.html) (HOC)
24+
React render. It works because it is a [Higher-Order component](https://reactjs.org/docs/higher-order-components.html) (HOC)
2525
assigned to a dictionary of elements depending on the target you've selected thus being able to pass the props you
2626
desire for your application but also containing the logic to interpolate the `SpringValues` from the hook you've used.
2727

2828
## Animating elements
2929

3030
The `animated` component can be imported from any of our targets. However, an `animated` component is specific to the target
31-
because they use the native elements of said target. These native elements are elements that are understood by the `react-reconciler`
32-
of choice e.g. [`@react-three/fiber`](https://github.com/pmndrs/react-three-fiber) is a reconciler for [`three.js`](https://threejs.org/)
33-
elements. So therefore any element that is understood by the reconciler can be animated.
31+
because it uses the native elements of said target. These native elements are elements that are understood by the `react-reconciler`
32+
of choice: e.g. [`@react-three/fiber`](https://github.com/pmndrs/react-three-fiber) is a reconciler for [`three.js`](https://threejs.org/)
33+
elements. Therefore, any element that the reconciler understands can be animated.
3434

3535
```jsx
3636
import { animated } from '@react-spring/web'
@@ -42,12 +42,12 @@ import { animated } from '@react-spring/web'
4242
<animated.mesh />
4343
```
4444

45-
If you've used `framer-motion` before, you will most likely be familiar with the dot notation of accessing a dictionary of components.
45+
If you used `framer-motion` before, you will most likely be familiar with the dot notation of accessing a dictionary of components.
4646

47-
So while being able to use `animated.element` is useful, most cases you'll want to style said element. `react-spring` has no preference on styling techniques,
48-
common techniques like `css modules` or [`tailwind`](https://tailwindcss.com/) can work because every animated element can accept the properties of the native element, e.g. `className`.
47+
So, while being able to use `animated.element` is useful, in most cases you'll want to style said element. `react-spring` has no preference about styling techniques:
48+
common techniques like `css modules` or [`tailwind`](https://tailwindcss.com/) all work, because every animated element accepts the properties of the native element, e.g. `className`.
4949

50-
If you're using a css-in-js library to style your components then typically you'll have access to a `styled` function. Just like composing components you can compose
50+
If you're using a CSS-in-JS library to style your components, you'll typically have access to a `styled` function. Just like composing components you can compose
5151
your animated element with the `styled` function:
5252

5353
```jsx
@@ -63,8 +63,8 @@ const MyModal = styled(animated.div, {
6363

6464
## Animating components
6565

66-
Sometimes it's not possible to animate an element directly e.g. because it comes from another library, for example [`radix-ui`](https://www.radix-ui.com/).
67-
Because `animated` is a HOC we can simply wrap our components with it and assuming the component you're wrapping passes to the `style` prop to the native element.
66+
Sometimes it's impossible to animate an element directly because it comes from another library, like [`radix-ui`](https://www.radix-ui.com/).
67+
Because `animated` is a HOC, we can simply wrap our components with it, assuming the component you're wrapping passes to the `style` prop to the native element.
6868

6969
```jsx
7070
// This comes from another library e.g. radix-ui
@@ -282,29 +282,29 @@ const Title = styled(Dialog.Title, {
282282
### How does it work?
283283

284284
Higher-order components have access to the props you're passing to the child. Therefore,
285-
the `animated` component is able to scan through the passed `style` prop and handle said values.
286-
How the component handles the style prop is dependant of the target you're using. For the
287-
purpose of explanation, we'll focus on the `web` target.
285+
the `animated` component can scan through the passed `style` prop and handle said values.
286+
How the component handles the style prop is dependent on the target you're using.
287+
Let's concentrate on the `web` target for the sake of explanation.
288288

289-
We start by extracting the whole `style` prop and wrapping it in an `AnimatedStyle` class, this
289+
We start by extracting the whole `style` prop and wrapping it in an `AnimatedStyle` class; this
290290
class is unique to the `web` target and handles the shorthands for transformations and in theory
291-
could handle a multitude of interpolations if we were to add them. Once we've performed the specific
292-
target alterations to the style prop we call the `super` of it's class `AnimatedObject` which then runs
291+
could handle a multitude of interpolations if we were to add them. Once we performed the specific
292+
target alterations to the style prop we call the `super` of its class `AnimatedObject`, which then runs
293293
through the object making the values "animated".
294294

295295
### How does it update the native element without causing a react render?
296296

297-
Similar to how the `style` prop is handled with regards to it being specific to the target, how we apply
297+
Similar to how the `style` prop is handled in a target-specific manner, how we apply
298298
the animated values to the native element is also specific to the target. In the instance of the `web` target,
299-
we in the process of wrapping the element in the `animated` HOC attach a ref to the element.
299+
during the process of wrapping the element in the `animated` HOC we attach a `ref` to the element.
300300

301301
We are then able to directly change the DOM node imperatively. For further reading, check out [`Controller`](/docs/concepts/controllers-and-springs#Controller).
302302

303303
### How can I make my own animated components?
304304

305305
Because animated components belong to the target, to create your own registry of animated components
306306
e.g. for a [D3](https://d3js.org/) react renderer, you would need to use the `createHost` function
307-
exported from the `@react-spring/animated` package. The signature for which looks like:
307+
exported from the `@react-spring/animated` package. Its signature looks like this:
308308

309309
```ts
310310
interface HostConfig {

0 commit comments

Comments
 (0)