-
Notifications
You must be signed in to change notification settings - Fork 85
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
breakpoints not updated in real time #222
Comments
this is most often caused by failure to connect the https://github.com/jaredh159/tailwind-react-native-classnames#enabling-device-context-prefixes Did you do that step as described? Also, fwiw, this library does not aim to support RN web, so I can't really promise you'll get it working correctly in web context, but it should work fine for RN native. |
I added a file import { create } from 'twrnc'
// create the customized version...
const tw = create(require(`../../tailwind.config.js`)) // <- your path may differ
// ... and then this becomes the main function your app uses
export default tw Then in the file import tw from 'utils/tailwind'
const App = () => {
useDeviceContext(tw)
// ... Then finally in my component: import tw from 'utils/tailwind'
//...
<View
style={tw.style(
`flex-1 md:flex-initial flex flex-col items-center justify-center py-12 px-4 sm:px-6 lg:px-20 xl:px-24`
)}
/...
And the breakpoint is only used when I restart the app.
|
In fact if I add the hook directly to my component it works. If I add it to the main component |
hmmm... i'm wondering if you're using something that memoizes, check out this thread for more, the basic thought is that if you have something in your component tree that is memoizing and preventing re-renders, then you won't see re-renders from the device context hook at the top level: |
Didn't you state that this doesn't work out of the box in this discussion item? |
yeah, I don't know that i stated categorically and positively that it doesn't work, just that it's not a goal for this library to support rn web, so i'm not considering it a bug. it appears to not work, i've not tried it myself. my guess is that it has to do with the viewport changing and the tw function not listening for that change. the current functionality is wired up to listen to RN natives window dimensions object, which perhaps is not leveraged at all in a web context. i'm not sure, because again, i've never worked with rn web. |
For what it's worth, I'm using non-Expo ReactNativeWeb and the breakpoints work well! Might be an expo-only issue |
I am using breakpoints like
flex-1 lg:flex-none
but the right breakpoint is applied only on the first render of the page. After it is wrong. If I change the screen size on the web or I rotate the device on mobile the wrong property is applied.Is there a way to fix this behavior?
The text was updated successfully, but these errors were encountered: