Comments (5)
I guess there is something we could do to handle these cases explicitly. If a child component can be considered part of the parent component, they both can define (and must define) the same key. For example themr('Radio', style)
.
If you provide a theme via context it's going to work nicely because they use the same key but I guess that if you pass down a style to a parent of an specific type, it makes sense if this component writes in the context the updated theme. Therefore, the child would read from context the theme you passed to the parent via props.
This update is not breaking and has no downsides in my opinion apart from the cost of writing in the context when a theme is received
from react-css-themr.
@wtgtybhertgeghgtwtg
You can easily set the same theme for different keys when constructing context:
import css from './shared.css';
const context = {
ChildComponent: css,
ParentComponent: css
};
On the other hand, if you accept exactly the same theme in different components why not to use the same keys (names) for them?
UPDATE: If your case is about including a theme passed to props, then I believe the best way here is to explicitly extract child's theme from props and to pass it down. I've opened #24 to help with such cases.
UPDATE: The reason of avoiding context is that it can't hold dynamic values when using pure-rendering: facebook/react#2517
from react-css-themr.
Yeah, you're right, that's what we are doing with react-toolbox. Just using the same key for both child and parent if the belong to the same complex component
from react-css-themr.
@wtgtybhertgeghgtwtg What you are suggesting is a good old cascade when Parent component affects all possible Children on all levels deeper. Such behavior is unsafe and was meant to be eliminated by introduction of css-modules. However, ThemeProviders
could still be nested to make such behavior explicit and #19 tracks it.
@javivelasco I believe this issue can be closed.
from react-css-themr.
Cool, thanks @raveclassic !
from react-css-themr.
Related Issues (20)
- Receiving/passing ref HOT 7
- When using ExtractTextPlugin it break the app HOT 3
- Default theming example HOT 2
- Possible drop of support of using themr as decorator with TypeScript HOT 3
- Allow a theme composition function as option HOT 2
- Typescript compiler fails when using react css themr with error Default export of the module has or is using private name 'TReactCSSThemrTheme' HOT 3
- Backport switch to `prop-types` package to the v1 branch to add compat with react 16 HOT 5
- Publish a new version with React 16 on npm HOT 3
- Do context theme support tree shaking ?
- Context theming works when app is run but not working when app is built
- mismatch dependancy
- Themr with pure functions HOT 1
- Update to be react 16 compitable HOT 2
- how to override styling in default css for a themed component
- Has this project been abandoned? HOT 1
- Css selector with attribute not working
- Multiple class not working HOT 5
- [QUESTION] Move to Friends of React HOT 5
- Warning on console when using react v16.4 HOT 4
- React-css-themr worked perfectly locally but not worked when used it after publishing it and used it as component lib into other project HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-css-themr.