React Components
This document is general advice for creating and working with new components.
Referencing source files
To make referencing source files easier we have set up three simple aliases when working inside an app.
@client
which points tosrc/client/*
@server
which points tosrc/server/*
@shared
which points tosrc/shared/*
Example usage would be as follows:
Alternatively we can also create an index.ts
file in the atoms directory and export all of our atoms allowing us to reference multiple at once.
Supporting files
Our components may also contain other important files. For instance this framework supports the use of localized stylesheets with Logo.scss
. It is also highly recommended that all stories be accompanied by a README.md
file to help with development.
And finally we have our index.ts
. This file should simply export our component for consumption in the general application.
Connecting a component to state
If this component needs to connect to redux state then it will need the following file(s).
Here's a simple example of what this file might look like.
The reason for this separation is primarily for testability but it also allows us to use a component in multiple contexts (with or without redux). The only reference to a connected component should be with in our route config.