Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Clarify doc wording
Browse files Browse the repository at this point in the history
  • Loading branch information
LPGhatguy committed Aug 6, 2018
1 parent 8285d32 commit c78b760
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function MyComponent:init()
end
```

In older versions of Roact, `setState` was disallowed in `init`, and you would instead assign to `state` directly. This is still acceptable, but it's simpler to use `setState`:
In older versions of Roact, `setState` was disallowed in `init`, and you would instead assign to `state` directly. It's simpler to use `setState`, but assigning directly to `state` is still acceptable inside `init`:

```lua
function MyComponent:init()
Expand Down Expand Up @@ -298,7 +298,7 @@ Setting a field in the state to `Roact.None` will clear it from the state. This
* Lifecycle hooks: `willUnmount`
* Pure functions: `render`, `shouldUpdate`

Calling `setState` inside of `init` or `willUpdate` has different behavior in other places. Because Roact is already going to render or update a component in these cases, the update will be replaced instead of another update happening.
Calling `setState` inside of `init` or `willUpdate` has special behavior. Because Roact is already going to update a component in these cases, that update will be replaced instead of another being scheduled.

Roact may support calling `setState` in currently-disallowed places in the future.

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/state-and-lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ end

In this case, we're passing a _function_ to `setState`. This function is called and passed the current state, and returns a new state. It can also return `nil` to abort the state update, which lets Roact make some handy optimizations.

Right now, this version of `setState` is exactly the same as the form where we pass an object. In the future, Roact will support a number of features, like asynchronous rendering, that make the distinction more important.
Right now, this version of `setState` works exactly the same way as the version that accepts an object. In the future, Roact will support optimizations that make this difference more important, like [asynchronous rendering](https://github.com/Roblox/roact/issues/18).

## Lifecycle Methods
Stateful components can provide methods to Roact that are called when certain things happen to a component instance.
Expand Down

0 comments on commit c78b760

Please sign in to comment.