enpit / fleux

Towards Sane State Management in React

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prop Renaming

objectliteral opened this issue · comments

Currently, the names of values in the store and the names for these values used inside of components are always identical.

Suggestion: To avoid naming conflicts, it should be possible to map store keys to local keys when calling withState.

A working implementation of this feature existis on branch prop-renaming.

The implementation (see parseProps.ts) feels overly complicated though, which might be a result of the desire to account for many different styles of providing arguments to withState.

I suggest that a proposal is made, detailing the desired ways to call withState (and provide prop name mappings to it). After a good compromise between flexibility and API surface is found, the implementation should be revisited.

The branch prop-renaming will not be used any further three reasons: 1) As stated above, the implementation of parseProps and the overall API of withState felt confusing. 2) A first attempt at refactoring parseProps was made in feature/actions. 3) The issue of prop renaming is tackled by a mapStateToProps-like feature, which will be implemented in feature/mapStateToProps.

Since the distinction of read- and write-keys will be removed from fleux's API, there is no point in merging the existing implementation of prop renaming, but to wait for the more generic feature in the form of a mapStateToProps-equivalent.

Refer to #18