You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -198,6 +198,8 @@ For the definition of when each state is entered, see the [state machine definit
198
198
|`focusToggleOff`| boolean |`focusToggleOff`| Add this prop to prevent focus from toggling on mouseup/tap. With this prop RI will enter the focus state normally and will remain in the focus state until the browser sends a blur event. |
199
199
|`mutableProps`| boolean |`mutableProps`| Add this prop if you are passing in mutable props so the component will always update. By default it's assumed that props passed in are immutable. A shallow compare is done, and if the props are the same, the component will not update. If you're not sure and notice buggy behavior, then add this prop. |
200
200
|`interactiveChild`| boolean |`interactiveChild`| Add this prop if Interactive's children use the [Interactive Children API](#interactive-children-api). |
201
+
|`wrapperStyle`| style object |`{ display: 'block' }`| Styles that are applied to the `span` wrapper if `as` is a ReactComponent. |
202
+
|`wrapperClassName`| string |`"ri-wrapper-class other-class"`| Classes that are applied to the `span` wrapper if `as` is a ReactComponent. |
201
203
|`...`| anything |`id="some-id"`, `tabIndex="1"`, etc... | All additional props received are passed through. |
202
204
203
205
#### Merging Styles and Classes
@@ -222,6 +224,7 @@ For the definition of when each state is entered, see the [state machine definit
222
224
- Strictly speaking this means that `as` is either a ReactClass or a ReactFunctionalComponent as defined in the [React Glossary](https://facebook.github.io/react/docs/glossary.html#classes-and-components).
223
225
- In order for React Interactive to work `as` a ReactComponent, the component must pass down the props it receives from React Interactive to the top DOM node that it renders, and it cannot override any of the passed down event handlers, e.g. `onMouseEnter`. Also, the component cannot replace its top DOM node once it's rendered unless the replacement is the result of new props (note that mutations are okay, e.g. changing style, classes, children, etc is fine). This is because React Interactive keeps a reference to the component's top DOM node so it can do things like call `focus()`, and if the top DOM node is replaced without React Interactive's knowledge, then things start to break. Note that React Router's Link component meets these requirements.
224
226
- When `as` is a ReactComponent it is wrapped in a `<span>` in order for React Interactive to maintain a reference to the top DOM node without breaking encapsulation. Without the span wrapper the only way to access the top DOM node would be through using `ReactDOM.findDOMNode(component)`, which breaks encapsulation and is discouraged, and also doesn't work with stateless functional components.
227
+
- The `<span>` wrapper can be styled by passing down the props `wrapperClassName` (class string) and `wrapperStyle` (style object).
225
228
- If `as` is a JSX/ReactElement:
226
229
- E.g. `as={<div>...</div>}` or `as={<MyComponent />}`
227
230
- The props of the top ReactElement are merged with, and have priority over, Interactive's props. For example:
0 commit comments