Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(introduction): add "Quick Start" page #3651

Closed
wants to merge 1 commit into from

Conversation

bpas247
Copy link

@bpas247 bpas247 commented Dec 6, 2019

PR Type

Does this PR add a new page, or update an existing page?

  • Adds the "Quick Start" page,

Checklist

What docs page is being added or updated?

  • Section: Introduction
  • Page: QuickStart

For Adding New Content

What kind of content category is this page (tutorial, how-to, explanation, reference)?

tutorial.

Who is the intended target audience?

Redux users who want to quickly bootstrap their next project with the latest technologies.

What knowledge are we assuming they have?

Very minimal Redux knowledge, no prior Redux Toolkit experience needed. Basic JS and/or React knowledge.

What are the intended results or takeaways from reading this page?

To be able to gain just enough Redux and Redux Toolkit knowledge to be able to start their next project. They can learn Redux more in-depth in later tutorials.

What is the most critical info they should learn?

Learning the basics of Redux and Redux Toolkit, and how to tie those basics in to building vanilla or React based apps.

TODOs

  • Add CodeSandboxes to ensure the code runs properly
  • Add more links throughout the tutorial
  • Add links for external resources at the end of the page

Adds a Quick Start page, which will be used as a quick copy/paste
reference for users wanting to bootstrap their next project.
@netlify
Copy link

netlify bot commented Dec 6, 2019

Deploy preview for redux-docs ready!

Built with commit 3bf047f

https://deploy-preview-3651--redux-docs.netlify.com

Copy link
Author

@bpas247 bpas247 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, quite a few issues here. I'm not even sure if its worth iterating over this page as it is, might be easier just to scrap it and start from scratch 🤷‍♀

const substract = createAction('SUBSTRACT')
```

Here we're using Redux Toolkit's `createAction` to create the necessary actions we'll be using for the app.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to elaborate a bit more on why we define actions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also link to RTK's createAction docs.

- The second argument defines a "lookup table" object, where the key is the action type and the value is the reducer function associated with the action.
- In case you aren't familiar with the weird `[add]` syntax, it is known as the [ES6 object "computed property" syntax](https://javascript.info/object#computed-properties). This allows us to create keys from actions made with `createAction` with ease (since the computed properties ultimately calls `toString()` on those variables, which `createAction` objects overrides with the value of its type property).

The reducers' implementations should be fairly straightforward, simply adding or subtracting the action payload.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is making an unfair assumption on the reader's knowledge, consider revising the wording here.


At first glance this may be a little strange to look at, but let's unpack it:

- The first argument passed into `createReducer` is the initial state, which we'll start at `0`.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createReducer should link to RTK's docs.


Now this may leave you wondering "gee, why do I need to define action creators outside of the reducer? What if there was a way to bake action creators into the reducer itself?"

Well, that's where `createSlice` from Redux Toolkit comes in :)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should link to RTK's createSlice docs.

})
```

Now the `add` and `subtract` actions will be available via `calculatorSlice.actions` and the reducer function will be available via `calculatorSlice.reducer`. This keeps our "slice" of the store all in one place, so that we'll know where all of the logic for this part of the store resides.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should link to external resource on the concept of "slices" of stores.

})
```

Using Redux Toolkit's `configureStore`, we can setup the store with helpful default middleware out of the box. Unfortunately, this example won't be able to highlight this middleware, but be sure to check out the [included default middleware](https://redux-starter-kit.js.org/api/getDefaultMiddleware#included-default-middleware) to learn more about them.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should link to RTK's configureStore docs.

Comment on lines +150 to +151
alright, now we have a simple app setup that utilizes our Redux code to have a functioning calculator app. it will now dispatch actions to update the value in the store,
depending on which button was clicked.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes feel like I'm wanting more out of this explanation. Adding external resources might help? Or just a more in-depth explanation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also needs a runnable CodeSandbox here.

Comment on lines +185 to +186
<Button action={add(input)}>Add Amount</Button>
<Button action={subtract(input)}>Subtract Amount</Button>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks bad, I'm not sure why. It almost makes this code snippet unusable, since if I'm an end user copy/pasting this code I would most likely re-write this portion entirely.

- For the `Button` component, we use the `useDispatch` hook in order to dispatch the passed in actions.
- For the `App` component, we define the input element and its state here so that we can pass down the `value` of the input element to the `Button` components for dispatch. This allows the user to enter in a specified value to either add or subtract.

Great! Now we have a fully-functioning simple React calculator app :)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to external resources and runnable CodeSandbox example.

@@ -2,6 +2,7 @@
"docs": {
"Introduction": [
"introduction/getting-started",
"introduction/quick-start",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally not a fan of this placement. The first section out of this page is about installation, but the next page this navigates to is the Installation page?

@markerikson
Copy link
Contributor

I actually just opened up #3674 to cover creating a "Quick Start" page, and I'd forgotten that you'd filed this.

I just had some discussion with @taniarascia about some ideas for this, and I jotted some notes in that issue.

I'm going to skim yours, but then take a stab at putting together my own version.

@bpas247
Copy link
Author

bpas247 commented Jan 7, 2020

I'm going to skim yours, but then take a stab at putting together my own version.

Sounds good, should I go ahead and close this then?

@bpas247
Copy link
Author

bpas247 commented Mar 21, 2020

Superseded by #3675

@bpas247 bpas247 closed this Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants